?php namespace App\Controller; use Cake\ORM\TableRegistry; use Cake\Cache\Cache; use Cake\Network\Exception\NotFoundException; //use PHPMailer\PHPMailer\PHPMailer; //use PHPMailer\PHPMailer\Exception; use PHPMailer\PHPMailer\PHPMailer; use PHPMailer\PHPMailer\Exception; use PHPMailer\PHPMailer\POP3; use PHPMailer\PHPMailer\SMTP; use Cake\Event\Event; use Cake\Datasource\ConnectionManager; require_once ('/var/www/html/application/lib/google-api-php-client-2.2.0/vendor/autoload.php'); session_cache_limiter("nochashe"); class FrontsController extends AppController { //public $components = ['Img', 'Webp']; public $components = ['Img', 'Webp']; //public $helpers = ['String']; public $helpers = ['Form']; public function initialize(){ $this->name = 'Fronts'; //$this->autoRender = false; //$this->viewBuilder()->autoLayout(false); $this->viewBuilder()->layout('website'); //外部テーブル参照 $this->Companies = TableRegistry::get('Companies'); $this->Pages = TableRegistry::get('Pages'); $this->Blocks = TableRegistry::get('Blocks'); $this->Redirects = TableRegistry::get('Redirects'); $this->Settings = TableRegistry::get('Settings'); //$this->Newsettings = TableRegistry::get('Newsettings'); $this->AccessLogs = TableRegistry::get('AccessLogs'); $this->Shops = TableRegistry::get('Shops'); $this->Menus = TableRegistry::get('Menus'); $this->MenuCategories = TableRegistry::get('MenuCategories'); $this->Coupons = TableRegistry::get('Coupons'); $this->Staffs = TableRegistry::get('Staffs'); $this->StaffCategories = TableRegistry::get('StaffCategories'); $this->Galleries = TableRegistry::get('Galleries'); $this->GalleryCategories = TableRegistry::get('GalleryCategories'); $this->Questions = TableRegistry::get('Questions'); $this->QuestionCategories = TableRegistry::get('QuestionCategories'); $this->Comparisons = TableRegistry::get('Comparisons'); $this->ComparisonCategories = TableRegistry::get('ComparisonCategories'); $this->BlogCategories = TableRegistry::get('BlogCategories'); $this->BlogTags = TableRegistry::get('BlogTags'); $this->ColumnCategories = TableRegistry::get('ColumnCategories'); $this->ColumnTags = TableRegistry::get('ColumnTags'); $this->NewsCategories = TableRegistry::get('NewsCategories'); $this->MultigalleryCategories = TableRegistry::get('MultigalleryCategories'); $this->MultigalleryTags = TableRegistry::get('MultigalleryTags'); $this->FeatureCategories = TableRegistry::get('FeatureCategories'); $this->FeatureTags = TableRegistry::get('FeatureTags'); $this->Tags = TableRegistry::get('Tags'); $this->Contacts = TableRegistry::get('Contacts'); $this->ContactDetails = TableRegistry::get('ContactDetails'); $this->ContactLogs = TableRegistry::get('ContactLogs'); $this->Dictionaries = TableRegistry::get('Dictionaries'); $this->Navigations = TableRegistry::get('Navigations'); $this->Recruits = TableRegistry::get('Recruits'); $this->RecruitCategories = TableRegistry::get('RecruitCategories'); $this->Youtube = TableRegistry::get('Youtube'); $this->Infobizs = TableRegistry::get('Infobizs'); // $this->Newpages = TableRegistry::get('Newpages'); $this->Newblocks = TableRegistry::get('Newblocks'); $this->Newtools = TableRegistry::get('Newtools'); $this->Richresults = TableRegistry::get('Richresults'); $this->PopupBanners = TableRegistry::get('PopupBanners'); $this->FixBanners = TableRegistry::get('FixBanners'); // $this->Enquetes = TableRegistry::get('Enquetes'); $this->EnqueteDetails = TableRegistry::get('EnqueteDetails'); $this->LandingPages = TableRegistry::get('LandingPages'); $this->PillarPages = TableRegistry::get('PillarPages'); // $this->loadComponent('Newtool'); $this->loadComponent('Mail'); //$this->loadHelper('Form'); } /* public function beforeRender(Event $event) { parent::beforeRender($event); $this->viewBuilder()->helpers(['Form']); } */ public function beforeFilter(Event $event){ parent::beforeFilter($event); $www_mode = ''; //if($_SERVER['REQUEST_URI'] != '/fronts/mystyle-css/' && $_SERVER['REQUEST_URI'] != '/fronts/mystyle-js/' && $_SERVER['REQUEST_URI'] != '/fronts/original-css/'){ if(strpos($_SERVER['REQUEST_URI'], '/fronts/mystyle-css/') === false && strpos($_SERVER['REQUEST_URI'], '/fronts/mystyle-js/') === false && strpos($_SERVER['REQUEST_URI'], '/fronts/original-css/') === false && strpos($_SERVER['REQUEST_URI'], '/fronts/original-js/') === false && strpos($_SERVER['REQUEST_URI'], '/fronts/compress-css/') === false && strpos($_SERVER['REQUEST_URI'], '/fronts/compress-js/') === false && strpos($_SERVER['REQUEST_URI'], '/robots.txt') === false && strpos($_SERVER['REQUEST_URI'], '/rss/') === false && strpos($_SERVER['REQUEST_URI'], '/websub/') === false && strpos($_SERVER['REQUEST_URI'], '/images/convert/') === false && strpos($_SERVER['REQUEST_URI'], '/mails/ipp-new-mail-send/') === false && strpos($_SERVER['REQUEST_URI'], 'llms.txt') === false){ //不正アクセス対策 if(strpos($_SERVER['REQUEST_URI'],'.php') !== false){ exit(); } if(strpos($_SERVER['REQUEST_URI'],'/vendor/phpunit/') !== false){ exit(); } if(strpos($_SERVER['REQUEST_URI'],'/.vscode') !== false){ exit(); } if(strpos($_SERVER['REQUEST_URI'],'/.git') !== false){ exit(); } if(strpos($_SERVER['REQUEST_URI'],'/ini.php') !== false){ exit(); } if(strpos($_SERVER['REQUEST_URI'],'/meta.json') !== false){ exit(); } if(strpos($_SERVER['REQUEST_URI'],'/.well-known/content.php') !== false){ exit(); } if(strpos($_SERVER['REQUEST_URI'],'/webadmin.php') !== false){ exit(); } if(strpos($_SERVER['REQUEST_URI'],'/file.php') !== false){ exit(); } if(strpos($_SERVER['REQUEST_URI'],'/wp-configs.php') !== false){ exit(); } if(strpos($_SERVER['REQUEST_URI'],'/feeds.php') !== false){ exit(); } if(strpos($_SERVER['REQUEST_URI'],'/aaa.php') !== false){ exit(); } if(strpos($_SERVER['REQUEST_URI'],'/sxo.php') !== false){ exit(); } if(strpos($_SERVER['REQUEST_URI'],'/system.php') !== false){ exit(); } if(strpos($_SERVER['REQUEST_URI'],'/dsrdelete.json') !== false){ exit(); } if(strpos($_SERVER['REQUEST_URI'],'/data.tar.gz') !== false){ exit(); } if(strpos($_SERVER['REQUEST_URI'],'/backup.zip') !== false){ exit(); } if(strpos($_SERVER['REQUEST_URI'],'/x.php') !== false){ exit(); } if(strpos($_SERVER['REQUEST_URI'],'/input.php') !== false){ exit(); } if(strpos($_SERVER['REQUEST_URI'],'/update.php') !== false){ exit(); } if(strpos($_SERVER['REQUEST_URI'],'/configs.php') !== false){ exit(); } if(strpos($_SERVER['REQUEST_URI'],'/classwithtostring.php') !== false){ exit(); } if(strpos($_SERVER['REQUEST_URI'],'/admin.php') !== false){ exit(); } if(strpos($_SERVER['REQUEST_URI'],'/local.xml') !== false){ exit(); } if(strpos($_SERVER['REQUEST_URI'],'/cloud.php') !== false){ exit(); } if(strpos($_SERVER['REQUEST_URI'],'/plugin.php') !== false){ exit(); } if(strpos($_SERVER['REQUEST_URI'],'/NewFile.php') !== false){ exit(); } if(strpos($_SERVER['REQUEST_URI'],'/autoload_classmap.php') !== false){ exit(); } if(strpos($_SERVER['REQUEST_URI'],'/RxR.php') !== false){ exit(); } if(strpos($_SERVER['REQUEST_URI'],'/style.php') !== false){ exit(); } if(strpos($_SERVER['REQUEST_URI'],'/mt-xmlrpc.cgi') !== false){ exit(); } if(strpos($_SERVER['REQUEST_URI'],'/sck.php') !== false){ exit(); } if(strpos($_SERVER['REQUEST_URI'],'/sck.php') !== false){ exit(); } if(strpos($_SERVER['REQUEST_URI'],'/about.php') !== false){ exit(); } if(strpos($_SERVER['REQUEST_URI'],'/radio.php') !== false){ exit(); } if(strpos($_SERVER['REQUEST_URI'],'.env') !== false){ //$redirect_url_array = explode('?', $_SERVER['REQUEST_URI']); //return $this->redirect('https://'.$_SERVER['HTTP_HOST'].'/', '301'); exit(); } //WP対策 if(strpos($_SERVER['REQUEST_URI'],'/wp-content/') !== false){ //$redirect_url_array = explode('?', $_SERVER['REQUEST_URI']); //return $this->redirect('https://'.$_SERVER['HTTP_HOST'].'/', '301'); exit(); } if(strpos($_SERVER['REQUEST_URI'],'wp-include/') !== false){ //$redirect_url_array = explode('?', $_SERVER['REQUEST_URI']); //return $this->redirect('https://'.$_SERVER['HTTP_HOST'].'/', '301'); exit(); } if(strpos($_SERVER['REQUEST_URI'],'wp-includes/') !== false){ //$redirect_url_array = explode('?', $_SERVER['REQUEST_URI']); //return $this->redirect('https://'.$_SERVER['HTTP_HOST'].'/', '301'); exit(); } if(strpos($_SERVER['REQUEST_URI'],'/wp-admin') !== false){ //$redirect_url_array = explode('?', $_SERVER['REQUEST_URI']); //return $this->redirect('https://'.$_SERVER['HTTP_HOST'].'/', '301'); exit(); } if(strpos($_SERVER['REQUEST_URI'],'/wp-index.php') !== false){ //$redirect_url_array = explode('?', $_SERVER['REQUEST_URI']); //return $this->redirect('https://'.$_SERVER['HTTP_HOST'].'/', '301'); exit(); } if(strpos($_SERVER['REQUEST_URI'],'/wp-express.php') !== false){ //$redirect_url_array = explode('?', $_SERVER['REQUEST_URI']); //return $this->redirect('https://'.$_SERVER['HTTP_HOST'].'/', '301'); exit(); } // if(strpos($_SERVER['HTTP_HOST'],'wiple-service.com') !== false && strpos($_SERVER['REQUEST_URI'],'/ads.txt') !== false){ header( "HTTP/1.1 301 Moved Permanently" ); header( "Location: https://wiple-service.com/column/ads.txt" ); exit(); } // if(strpos($_SERVER['HTTP_HOST'],'isshin-kikaku.com') !== false && strpos($_SERVER['REQUEST_URI'],'/ads.txt') !== false){ header( "HTTP/1.1 301 Moved Permanently" ); header( "Location: https://isshin-kikaku.com/resources/ads.txt" ); exit(); } //URLの末尾にスラッシュが付いていない場合、リダイレクト if(substr($_SERVER['REQUEST_URI'], -1) != '/' && strpos($_SERVER['REQUEST_URI'], '?') === false && strpos($_SERVER['REQUEST_URI'], 'image.webp') === false){ return $this->redirect('https://'.$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI'].'/', '301'); } //pc-switcher対策 if(strpos($_SERVER['REQUEST_URI'],'?pc-switcher=') !== false){ $redirect_url_array = explode('?', $_SERVER['REQUEST_URI']); return $this->redirect('https://'.$_SERVER['HTTP_HOST'].$redirect_url_array[0], '301'); } //リダイレクトの暫定処理 if(strpos($_SERVER['HTTP_HOST'],'kaitoriwakaba-gamagori.jp') !== false || strpos($_SERVER['HTTP_HOST'],'kaitoriwakaba-okazaki.jp') !== false || strpos($_SERVER['HTTP_HOST'],'kaitoriwakaba-kariya.jp') !== false || strpos($_SERVER['HTTP_HOST'],'kaitoriwakaba-takahama.jp') !== false || strpos($_SERVER['HTTP_HOST'],'kaitoriwakaba-toyota.jp') !== false || strpos($_SERVER['HTTP_HOST'],'kaitoriwakaba-nishio.jp') !== false){ header( "HTTP/1.1 301 Moved Permanently" ); header( "Location: https://kaitori-wakaba.com/" ); exit(); } //リダイレクトの暫定処理(2) if(strpos($_SERVER['HTTP_HOST'],'sougisya-tomoshibi.com') !== false){ $request_url = $_SERVER['REQUEST_URI']; header( "HTTP/1.1 301 Moved Permanently" ); switch($request_url){ case '/': header( "Location: https://sogi-tomoshibi.com/" ); exit; case '/plan/': header( "Location: https://sogi-tomoshibi.com/plan/" ); exit; case '/plan/plan1/': header( "Location: https://sogi-tomoshibi.com/plan/kaso/" ); exit; case '/plan/plan2/': header( "Location: https://sogi-tomoshibi.com/plan/oneday/" ); exit; case '/plan/plan3/': header( "Location: https://sogi-tomoshibi.com/plan/family/" ); exit; case '/concept/': header( "Location: https://sogi-tomoshibi.com/reason/" ); exit; case '/saijyo/': header( "Location: https://sogi-tomoshibi.com/area/" ); exit; case '/saijyo/saijyo1/': header( "Location: https://sogi-tomoshibi.com/area/saitama/" ); exit; case '/saijyo/saijyo2/': header( "Location: https://sogi-tomoshibi.com/area/tokyo/" ); exit; case '/saijyo/saijyo3/': header( "Location: https://sogi-tomoshibi.com/area/chiba/" ); exit; case '/faq/': header( "Location: https://sogi-tomoshibi.com/#:~:text=%E3%82%A2%E3%83%95%E3%82%BF%E3%83%BC%E3%82%B5%E3%83%9D%E3%83%BC%E3%83%88%E2%BC%80%E8%A6%A7-,%E3%82%88%E3%81%8F%E3%81%82%E3%82%8B%E3%81%94%E8%B3%AA%E5%95%8F,-%E3%81%94%E5%AE%B6%E6%97%8F%E6%A7%98" ); exit; case '/howto/': header( "Location: https://sogi-tomoshibi.com/blog/" ); exit; case '/company/': header( "Location: https://sogi-tomoshibi.com/about/" ); exit; case '/contact/': header( "Location: https://sogi-tomoshibi.com/contact/" ); exit; case '/privacy_policy/': header( "Location: https://sogi-tomoshibi.com/contact/#:~:text=%E3%83%97%E3%83%A9%E3%82%A4%E3%83%90%E3%82%B7%E3%83%BC%E3%83%9D%E3%83%AA%E3%82%B7%E3%83%BC,%E3%81%A3%E3%81%A6%E3%81%8A%E3%82%8A%E3%81%BE%E3%81%99" ); exit; default: header( "Location: https://sogi-tomoshibi.com/" ); exit; } } //リダイレクトの暫定処理(3) if(strpos($_SERVER['HTTP_HOST'],'tsutsuik.co.jp') !== false){ $request_url = $_SERVER['REQUEST_URI']; header( "HTTP/1.1 301 Moved Permanently" ); switch($request_url){ case '/consulting_concept/': header( "Location: https://tsutsuik.jp/" ); exit; case '/consulting_concept/event/category/LAB%E3%83%97%E3%83%AD%E3%83%95%E3%82%A1%E3%82%A4%E3%83%AB%C2%AE%EF%BC%86%E3%82%B3%E3%83%BC%E3%83%81%E3%83%B3%E3%82%B0%E3%82%BB%E3%83%9F%E3%83%8A%E3%83%BC/': header( "Location: https://tsutsuik.jp/" ); exit; case '/consulting_concept/event/detail/20220520123713/': header( "Location: https://tsutsuik.jp/" ); exit; case '/consulting_concept/event/detail/20220520123631/': header( "Location: https://tsutsuik.jp/" ); exit; case '/consulting_concept/voice/': header( "Location: https://tsutsuik.jp/" ); exit; default: /*header( "HTTP/1.1 301 Moved Permanently" ); header( "Location: https://tsutsuik.jp/" ); exit;*/ } } //リダイレクトの暫定処理(4) //if($_SERVER['HTTP_HOST'] == 'ushizikoumuten.com' && $_SERVER['REQUEST_URI'] == '/'){ //if($_SERVER['HTTP_HOST'] == 'ushizikoumuten.com'){ if(strpos($_SERVER['HTTP_HOST'],'ushizikoumuten.com') !== false){ /*header( "HTTP/1.1 301 Moved Permanently" ); header( "Location: http://www.ushichikoumuten.jp/works/" ); exit;*/ $request_url = $_SERVER['REQUEST_URI']; header("HTTP/1.1 301 Moved Permanently"); switch($request_url){ case '/concept/': header("Location: https://www.ushichikoumuten.jp/professional/"); exit; case '/concept/reviews/': header("Location: https://www.ushichikoumuten.jp/cat46/post_9.html"); exit; case '/concept/reputation/': header("Location: https://www.ushichikoumuten.jp/cat46/post_9.html"); exit; case '/concept/voice/': header("Location: https://www.ushichikoumuten.jp/cat46/post_9.html"); exit; case '/service/': header("Location: https://www.ushichikoumuten.jp/buildhouse/"); exit; case '/staff/': header("Location: https://www.ushichikoumuten.jp/constructionstaff/"); exit; case '/works/': header("Location: https://www.ushichikoumuten.jp/works/"); exit; case '/faq/': header("Location: https://www.ushichikoumuten.jp/booklet-ssl/"); exit; case '/company/': header("Location: https://www.ushichikoumuten.jp/company/"); exit; case '/company/ushizikoumuten/': header("Location: https://www.ushichikoumuten.jp/company/"); exit; case '/blog/': header("Location: https://www.ushichikoumuten.jp/diaryblog/"); exit; case '/contact/': header("Location: https://www.ushichikoumuten.jp/contact-ssl/"); exit; case '/privacy_policy/': header("Location: https://www.ushichikoumuten.jp/privacy/"); exit; case '/sitemap/': header("Location: https://www.ushichikoumuten.jp/archives.html"); exit; case '/': header("Location: https://www.ushichikoumuten.jp/"); exit; default: /*header( "HTTP/1.1 301 Moved Permanently" ); header( "Location: https://tsutsuik.jp/" ); exit;*/ } if(strpos($request_url,'/works/detail/') !== false){ header("Location: https://www.ushichikoumuten.jp/works/"); exit; } if(strpos($request_url,'/blog/detail/') !== false){ header("Location: https://www.ushichikoumuten.jp/diaryblog/"); exit; } } //リダイレクトの暫定処理(5) if($_SERVER['HTTP_HOST'] == 'hosana437-shop.com'){ header( "HTTP/1.1 301 Moved Permanently" ); header( "Location: https://www.hosanashop-gaura.com/" ); exit; } //リダイレクトの暫定処理(6):231227:https://areus.backlog.jp/view/IPP3_CORRECTION-4071 if($_SERVER['HTTP_HOST'] == 'shozanryu.jp' && strpos($_SERVER['REQUEST_URI'],'/admin/') === false){ header( "HTTP/1.1 301 Moved Permanently" ); header( "Location: https://shozanryu.com/" ); exit; } //リダイレクトの暫定処理(7):231227:https://areus.backlog.jp/view/IPP3_CORRECTION-4326 if(strpos($_SERVER['HTTP_HOST'],'ariake-skin.jp') !== false){ $request_url = $_SERVER['REQUEST_URI']; header( "HTTP/1.1 301 Moved Permanently" ); switch($request_url){ case '/new/': header( "Location: https://ariakeskin-garden.child-clinic.or.jp/%e3%83%96%e3%83%ad%e3%82%b0/" ); exit; case '/strength/': header( "Location: https://ariakeskin-garden.child-clinic.or.jp/feature/" ); exit; case '/about/': header( "Location: https://ariakeskin-garden.child-clinic.or.jp/about/" ); exit; case '/beginner/': header( "Location: https://ariakeskin-garden.child-clinic.or.jp/first-time/" ); exit; case '/menu/': header( "Location: https://ariakeskin-garden.child-clinic.or.jp/" ); exit; case '/menu/dermatology/': header( "Location: https://ariakeskin-garden.child-clinic.or.jp/ippanhihuka/" ); exit; case '/menu/plasticsurgery/': header( "Location: https://ariakeskin-garden.child-clinic.or.jp/keiseigeka/" ); exit; case '/menu/cosmeticdermatology/': header( "Location: https://ariakeskin-garden.child-clinic.or.jp/biyouhihuka/" ); exit; case '/menu/injection/': header( "Location: https://ariakeskin-garden.child-clinic.or.jp/drip/" ); exit; case '/menu/cosmetics,-supplements,-food/': header( "Location: https://ariakeskin-garden.child-clinic.or.jp/cosme/" ); exit; case '/menu/laser/': header( "Location: https://ariakeskin-garden.child-clinic.or.jp/%e8%84%b1%e6%af%9b/" ); exit; case '/menu/epi_kids/': header( "Location: https://ariakeskin-garden.child-clinic.or.jp/%e8%84%b1%e6%af%9b/" ); exit; case '/menu/alopecia/': header( "Location: https://ariakeskin-garden.child-clinic.or.jp/%e8%84%b1%e6%af%9b%e7%97%87/" ); exit; case '/menu/medical-slimming/': header( "Location: https://ariakeskin-garden.child-clinic.or.jp/%e5%8c%bb%e7%99%82%e7%97%a9%e8%ba%ab/" ); exit; case '/menu/20221202171909/': header( "Location: https://ariakeskin-garden.child-clinic.or.jp/%e3%82%a2%e3%83%bc%e3%83%88%e3%83%a1%e3%82%a4%e3%82%af/" ); exit; case '/price-list/': header( "Location: https://ariakeskin-garden.child-clinic.or.jp/price/" ); exit; case '/menu/epi_kids/': header( "Location: https://ariakeskin-garden.child-clinic.or.jp/%e8%84%b1%e6%af%9b/" ); exit; case '/menu/cosmeticdermatology/': header( "Location: https://ariakeskin-garden.child-clinic.or.jp/biyouhihuka/" ); exit; case '/menu/injection/': header( "HTTP/1.1 301 Moved Permanently" ); header( "Location: https://ariakeskin-garden.child-clinic.or.jp/drip/" ); exit; case '/bruise_kids/': header( "Location: https://ariakeskin-garden.child-clinic.or.jp/%e3%81%93%e3%81%a9%e3%82%82%e3%81%ae%e3%81%82%e3%81%96%e6%b2%bb%e7%99%82/" ); exit; case '/news/detail/20210322153908/': header( "Location: https://ariakeskin-garden.child-clinic.or.jp/announcements/10964/" ); exit; case '/': header( "Location: https://ariakeskin-garden.child-clinic.or.jp/" ); exit; default: /*header( "HTTP/1.1 301 Moved Permanently" ); header( "Location: https://ariakeskin-garden.child-clinic.or.jp/" ); exit;*/ } if(strpos($_SERVER['REQUEST_URI'],'/news/') !== false && strpos($_SERVER['REQUEST_URI'],'/news/detail/20210322153908/') === false){ header( "HTTP/1.1 301 Moved Permanently" ); header( "Location: https://ariakeskin-garden.child-clinic.or.jp/announcements/" ); exit; } if(strpos($_SERVER['REQUEST_URI'],'/blog/') !== false){ header( "HTTP/1.1 301 Moved Permanently" ); header( "Location: https://ariakeskin-garden.child-clinic.or.jp/%e3%83%96%e3%83%ad%e3%82%b0/" ); exit; } } //リダイレクトの暫定処理(8):240611:https://areus.backlog.jp/view/IPP3_CORRECTION-4832 if(strpos($_SERVER['HTTP_HOST'],'selfcare-advicecenter.com') !== false){ $request_url = $_SERVER['REQUEST_URI']; header( "HTTP/1.1 301 Moved Permanently" ); switch($request_url){ case '/feature/counseling/': header( "Location: https://karadajyuku-selfcare.com/services/counseling.html" ); exit; case '/feature/therapy/': header( "Location: https://karadajyuku-selfcare.com/services/treatment.html" ); exit; case '/feature/self--care/': header( "Location: https://karadajyuku-selfcare.com/services/self-care.html" ); exit; case '/feature/training/': header( "Location: https://karadajyuku-selfcare.com/services/training.html" ); exit; case '/feature/after-support/': header( "Location: https://karadajyuku-selfcare.com/services/support.html" ); exit; case '/feature/device/': header( "Location: https://karadajyuku-selfcare.com/services/koushuuha.html" ); exit; case '/new/detail/20230624160045/': header( "Location: https://karadajyuku-selfcare.com/seitai/neokiyoutuu.html" ); exit; case '/new/detail/20230608133156/': header( "Location: https://karadajyuku-selfcare.com/seitai/vitamin-youtuu-nikkouyoku.html" ); exit; case '/new/detail/20231211161216/': header( "Location: https://karadajyuku-selfcare.com/seitai/kosi-kenninn-kouka.html" ); exit; case '/new/detail/20230719164931/': header( "Location: https://karadajyuku-selfcare.com/seitai/omoimono-youtuu.html" ); exit; case '/new/detail/20230902165648/': header( "Location: https://karadajyuku-selfcare.com/seitai/senaka-kinn-katai-itami.html" ); exit; case '/new/detail/20230909131408/': header( "Location: https://karadajyuku-selfcare.com/seitai/sebone-yawarakaku.html" ); exit; case '/new/detail/20231126171355/': header( "Location: https://karadajyuku-selfcare.com/seitai/oxytocin-massage.html" ); exit; case '/new/detail/20231102104708/': header( "Location: https://karadajyuku-selfcare.com/blog/yagutinowatasi-nousinnkeigeka-kurinikku.html" ); exit; case '/new/detail/20230807173950/': header( "Location: https://karadajyuku-selfcare.com/blog/orenokinniku-kamukamu-sinnkamata.html" ); exit; case '/new/detail/20230612132145/': header( "Location: https://karadajyuku-selfcare.com/seitai/kokyuu-doro-inn.html" ); exit; case '/new/detail/20230610153553/': header( "Location: https://karadajyuku-selfcare.com/seitai/rinnpa-jyunnkann.html" ); exit; case '/new/detail/20230824124743/': header( "Location: https://karadajyuku-selfcare.com/seitai/asa-youtuu.html" ); exit; case '/new/detail/20230517212639/': header( "Location: https://karadajyuku-selfcare.com/seitai/youtuu-katakori.html" ); exit; case '/new/detail/20240117121052/': header( "Location: https://karadajyuku-selfcare.com/seitai/orannda-toshuryouhou.html" ); exit; case '/new/detail/20230923174323/': header( "Location: https://karadajyuku-selfcare.com/seitai/taikann-dukuri.html" ); exit; case '/new/detail/20231022105205/': header( "Location: https://karadajyuku-selfcare.com/seitai/oukakumaku-kokyuu.html" ); exit; case '/new/detail/20240304155740/': header( "Location: https://karadajyuku-selfcare.com/seitai/sorigosi-pokkorionaka.html" ); exit; case '/new/detail/20240214203217/': header( "Location: https://karadajyuku-selfcare.com/seitai/itami-kurikaesu-sutoresu.html" ); exit; case '/new/detail/20231216103330/': header( "Location: https://karadajyuku-selfcare.com/seitai/selfcare-youtuu-katakori.html" ); exit; case '/new/detail/20231011185122/': header( "Location: https://karadajyuku-selfcare.com/seitai/selfcare-hie-youtuu.html" ); exit; case '/new/detail/20230617154724/': header( "Location: https://karadajyuku-selfcare.com/seitai/youtuu-taisaku-kokyuu.html" ); exit; case '/new/detail/20230524162250/': header( "Location: https://karadajyuku-selfcare.com/seitai/rouka-to-karei.html" ); exit; case '/new/detail/20230804125910/': header( "Location: https://karadajyuku-selfcare.com/seitai/hizatuu-nannkotu.html" ); exit; case '/new/detail/20240301114648/': header( "Location: https://karadajyuku-selfcare.com/seitai/sonnzai-igi.html" ); exit; case '/new/detail/20230903132125/': header( "Location: https://karadajyuku-selfcare.com/seitai/sekityuu-jiritusinnkei.html" ); exit; case '/new/detail/20231221095200/': header( "Location: https://karadajyuku-selfcare.com/seitai/selfcare-futann-keigenn.html" ); exit; case '/new/detail/20231209162659/': header( "Location: https://karadajyuku-selfcare.com/seitai/youtuu-kikenn.html" ); exit; case '/new/detail/20240116090022/': header( "Location: https://karadajyuku-selfcare.com/seitai/rigakuryouhousi.html" ); exit; case '/new/detail/20231214093250/': header( "Location: https://karadajyuku-selfcare.com/seitai/youtuu-korusetto-kouka.html" ); exit; case '/new/detail/20231223115139/': header( "Location: https://karadajyuku-selfcare.com/seitai/selfcare-yowasa-nigate-torimodosu.html" ); exit; case '/new/detail/20230916120550/': header( "Location: https://karadajyuku-selfcare.com/seitai/nekoze-senaka-appaku.html" ); exit; case '/new/detail/20231119101533/': header( "Location: https://karadajyuku-selfcare.com/seitai/tuukaku-henntyousei-toutuu.html" ); exit; case '/new/detail/20231106152504/': header( "Location: https://karadajyuku-selfcare.com/seitai/tuukaku-henntyousei-toutuu-selfcare.html" ); exit; case '/example/detail/467192/': header( "Location: https://karadajyuku-selfcare.com/seitai/tozann-youtuu.html" ); exit; case '/example/detail/422223/': header( "Location: https://karadajyuku-selfcare.com/voices/post-2636.html" ); exit; case '/example/detail/510603/': header( "Location: https://karadajyuku-selfcare.com/voices/post-2485.html" ); exit; case '/example/detail/452529/': header( "Location: https://karadajyuku-selfcare.com/voices/post-2640.html" ); exit; case '/concept/': header( "Location: https://karadajyuku-selfcare.com" ); exit; case '/menu/': header( "Location: https://karadajyuku-selfcare.com/menu/" ); exit; case '/staff/': header( "Location: https://karadajyuku-selfcare.com/shop/" ); exit; case '/feature/': header( "Location: https://karadajyuku-selfcare.com/service/" ); exit; case '/new/': header( "Location: https://karadajyuku-selfcare.com/seitai/" ); exit; case '/access/': header( "Location: https://karadajyuku-selfcare.com/shop/" ); exit; case '/': header( "Location: https://karadajyuku-selfcare.com/" ); exit; default: /*header( "HTTP/1.1 301 Moved Permanently" ); header( "Location: https://ariakeskin-garden.child-clinic.or.jp/" ); exit;*/ } } //リダイレクトの暫定処理(9):240611:https://areus.backlog.jp/view/IPP3_CORRECTION-4861 if($_SERVER['HTTP_HOST'] == 'bikou-ageo.com'){ header( "HTTP/1.1 301 Moved Permanently" ); header( "Location: https://bikouageo.com/" ); exit; } //リダイレクトの暫定処理(10):250411:https://areus.backlog.jp/view/IPP3_CORRECTION-6015 if($_SERVER['HTTP_HOST'] == 'bcs-hot.com'){ header( "HTTP/1.1 301 Moved Permanently" ); header( "Location: https://bc-hot.com/" ); exit; } //リダイレクトの暫定処理(11):250418-20261031:https://areus.backlog.jp/view/IPP3_CORRECTION-6047 if(strpos($_SERVER['HTTP_HOST'],'sanden-ser.com') !== false){ $request_url = $_SERVER['REQUEST_URI']; header( "HTTP/1.1 301 Moved Permanently" ); switch($request_url){ case '/': header( "Location: https://sanden-service.com/" ); exit; case '/concept/': header( "Location: https://sanden-service.com/thought" ); exit; case '/concept/reviews/': header( "Location: https://sanden-service.com/reason" ); exit; case '/concept/reputation/': header( "Location: https://sanden-service.com/reason" ); exit; case '/concept/voice/': header( "Location: https://sanden-service.com/reason" ); exit; case '/service/': header( "Location: https://sanden-service.com/reason" ); exit; case '/message/': header( "Location: https://sanden-service.com/company" ); exit; case '/gallery/': header( "Location: https://sanden-service.com/service" ); exit; case '/faq/': header( "Location: https://sanden-service.com/service" ); exit; case '/company/': header( "Location: https://sanden-service.com/company" ); exit; case '/company/sanden/': header( "Location: https://sanden-service.com/history" ); exit; case '/comic2/': header( "Location: https://sanden-service.com/recruit#comic01" ); exit; case '/comic/': header( "Location: https://sanden-service.com/recruit#comic02" ); exit; case '/blog/': header( "Location: https://sanden-service.com/blog" ); exit; case '/contact/': header( "Location: https://sanden-service.com/contact" ); exit; case '/privacy_policy/': header( "Location: https://sanden-service.com/contact" ); exit; case '/blog/detail/20210916110206/': header( "Location: https://sanden-service.com/blog" ); exit; case '/blog/detail/20210916111539/': header( "Location: https://sanden-service.com/blog" ); exit; case '/blog/detail/20210916111827/': header( "Location: https://sanden-service.com/blog" ); exit; case '/blog/detail/20210916112029/': header( "Location: https://sanden-service.com/blog" ); exit; case '/blog/detail/20210916112514/': header( "Location: https://sanden-service.com/blog" ); exit; case '/blog/detail/20210916112640/': header( "Location: https://sanden-service.com/blog" ); exit; case '/blog/detail/20210916113044/': header( "Location: https://sanden-service.com/blog" ); exit; case '/blog/detail/20210916113149/': header( "Location: https://sanden-service.com/blog" ); exit; case '/blog/detail/20210916113253/': header( "Location: https://sanden-service.com/blog" ); exit; case '/blog/detail/20210916113529/': header( "Location: https://sanden-service.com/blog" ); exit; case '/blog/detail/20210916113743/': header( "Location: https://sanden-service.com/blog" ); exit; case '/blog/detail/20210916114345/': header( "Location: https://sanden-service.com/blog" ); exit; case '/blog/detail/20211015163356/': header( "Location: https://sanden-service.com/blog" ); exit; case '/blog/detail/20211015163805/': header( "Location: https://sanden-service.com/blog" ); exit; case '/blog/detail/20211105112940/': header( "Location: https://sanden-service.com/blog" ); exit; case '/blog/detail/20211117160525/': header( "Location: https://sanden-service.com/blog" ); exit; case '/blog/detail/20211119150630/': header( "Location: https://sanden-service.com/blog" ); exit; case '/blog/detail/20211121223731/': header( "Location: https://sanden-service.com/blog" ); exit; case '/blog/detail/20211128144455/': header( "Location: https://sanden-service.com/blog" ); exit; case '/blog/detail/20211228174510/': header( "Location: https://sanden-service.com/blog" ); exit; case '/blog/detail/20220107233715/': header( "Location: https://sanden-service.com/blog" ); exit; case '/blog/detail/20220622180525/': header( "Location: https://sanden-service.com/blog" ); exit; case '/blog/detail/20220713051501/': header( "Location: https://sanden-service.com/blog" ); exit; case '/blog/detail/20221109104300/': header( "Location: https://sanden-service.com/blog" ); exit; case '/blog/detail/20221128145822/': header( "Location: https://sanden-service.com/blog" ); exit; case '/blog/detail/20230209202516/': header( "Location: https://sanden-service.com/blog" ); exit; case '/blog/detail/20230221215459/': header( "Location: https://sanden-service.com/blog" ); exit; default: header( "Location: https://sanden-service.com/" ); exit; } } //リダイレクトの暫定処理(12)2026/06/30 if($_SERVER['HTTP_HOST'] == 'souzokufudousan-kumamoto.com'){ $request_url = $_SERVER['REQUEST_URI']; header( "HTTP/1.1 301 Moved Permanently" ); header( "Location: https://akariterrace-es.com".$request_url ); exit(); } //リダイレクトの暫定処理(13):2026/07/31:https://areus.backlog.jp/view/IPP3_CORRECTION-6656 if($_SERVER['HTTP_HOST'] == 'assist-kobe-suma.jp'){ header( "HTTP/1.1 301 Moved Permanently" ); header( "Location: https://assist-kobe.jp/" ); exit(); } //企業情報取得 $query = $this->Companies->find() ->where(['Companies.status' => 1]) ->where(['Companies.delete_flag' => 0]); //顧客用サブドメインによるアクセスの場合 //if((strpos($_SERVER['HTTP_HOST'],'onerank-cms.com') !== false) && ($_SERVER['HTTP_HOST'] != 'onerank-cms.com')){ if((strpos($_SERVER['HTTP_HOST'],'onerank-cms.com') !== false && $_SERVER['HTTP_HOST'] != 'onerank-cms.com') || (strpos($_SERVER['HTTP_HOST'],'onerank-cms-2.com') !== false && $_SERVER['HTTP_HOST'] != 'onerank-cms-2.com') || (strpos($_SERVER['HTTP_HOST'],'onerank-cms-3.com') !== false && $_SERVER['HTTP_HOST'] != 'onerank-cms-3.com') || (strpos($_SERVER['HTTP_HOST'],'onerank-hybrid-dev.com') !== false && $_SERVER['HTTP_HOST'] != 'onerank-hybrid-dev.com') || (strpos($_SERVER['HTTP_HOST'],'onerank-hybrid-dev2.com') !== false && $_SERVER['HTTP_HOST'] != 'onerank-hybrid-dev2.com') || (strpos($_SERVER['HTTP_HOST'],'onerank-hybrid-dev3.com') !== false && $_SERVER['HTTP_HOST'] != 'onerank-hybrid-dev3.com') || (strpos($_SERVER['HTTP_HOST'],'ip-lambda.org') !== false && $_SERVER['HTTP_HOST'] != 'ip-lambda.org')){ $query->where(['Companies.subdomain' => SUB_DOMAIN]); $domain_name = $_SERVER['HTTP_HOST']; $www_mode = ''; $subdomain_mode = 'on'; //顧客専本ドメインによるアクセスの場合 }else{ //wwwありなしの確認 if(substr($_SERVER['HTTP_HOST'], 0, 4) == 'www.'){ $www_mode = 'on'; $domain_name = str_replace('www.', '', $_SERVER['HTTP_HOST']); }else{ $www_mode = 'off'; $domain_name = $_SERVER['HTTP_HOST']; } //$query->where(['Companies.domain' => $_SERVER['HTTP_HOST']]); $query->where(['Companies.domain' => $domain_name]); $subdomain_mode = 'off'; } $company = $query->first(); //DXツールのみの転送処理 if($company->cms_type == 64 || $company->cms_type == 65 || $company->cms_type == 66 || $company->cms_type == 67 || $company->cms_type == 68){ if(strpos($_SERVER['REQUEST_URI'], '/youtube/') !== false){ }elseif(strpos($_SERVER['REQUEST_URI'], 'preventions') === false){ return $this->redirect('/preventions/'); } } // if(!defined('SUB_DOMAIN')){ define('SUB_DOMAIN',$company->subdomain); } // //$setting = $this->setting_data($company->id); $tmp_setting = $this->setting_data($company->id); $setting = $tmp_setting['setting']; //$newsetting = $tmp_setting['newsetting']; //サブドメインから本ドメインへのリダイレクト //if($www_mode == '' && $company->domain_flag == 1){ if($subdomain_mode == 'on' && $company->domain_flag == 1){ if($setting->www_flag == 1){ return $this->redirect('https://'.$company->domain.$_SERVER['REQUEST_URI'], '301'); }elseif($setting->www_flag == 2){ return $this->redirect('https://www.'.$company->domain.$_SERVER['REQUEST_URI'], '301'); }else{ return $this->redirect('https://'.$company->domain.$_SERVER['REQUEST_URI'], '301'); } } //wwwありなしのリダイレクト設定 //www無し (www有りから無しにリダイレクト) if($setting->www_flag == 1 && $www_mode == 'on' && $subdomain_mode = 'off'){ return $this->redirect('https://'.$domain_name.$_SERVER['REQUEST_URI'], '301'); //www有り (www無しから有りにリダイレクト) }elseif($setting->www_flag == 2 && $www_mode == 'off' && $subdomain_mode = 'off'){ return $this->redirect('https://www.'.$domain_name.$_SERVER['REQUEST_URI'], '301'); //両方 (wwwありなしどちらでもアクセス可) }elseif($setting->www_flag == 3){ //未設定 }else{ } // //if($company->cms_version == 1 && $_SERVER['REQUEST_URI'] != '/sitemap/xml/'){ if($company->cms_version >= 1 && $_SERVER['REQUEST_URI'] != '/sitemap/xml/' && $_SERVER['REQUEST_URI'] != '/areus-tools/url-list/'){ $this->setAction('newrouting', $company, $setting, $domain_name); return; } } } public function index(){ } public function newrouting($company = null, $setting = null, $domain_name = null){ //session_cache_limiter('none'); $session = $this->request->getSession(); //変数宣言 $slug = ''; $slug_plus = ''; $fixed_slug = ''; $fixed_slug2 = ''; $parent_slug = ''; $parent_kind = ''; $slug_mode = ''; $archive_year = ''; $archive_month = ''; $request_uri = ''; $form_block_id = ''; $page_mode = ''; $iframe_mode = ''; $preview_mode = ''; $page_num = ''; //※※※setAction()で処理が2回走る、追って原因確認 if(isset($company->id) && is_numeric($company->id)){ $data['company'] = $company; // //$data['setting'] = $this->setting_data($company->id); $data['setting'] = $setting; //header SNS $sns_content = []; $sp_header_others = 0; $footer_display_flag = 0; if(!empty($data['setting']->sns_content)){ $sns_content_json = json_decode($data['setting']->sns_content, true); $sns_content['blog']['account'] = $sns_content_json['ameblo_id']; $sns_content['blog']['footer'] = $sns_content_json['ameblo_footer']; $sns_content['blog']['pc_header'] = $sns_content_json['ameblo_pc_header']; $sns_content['blog']['sp_header'] = $sns_content_json['ameblo_sp_header']; $sns_content['facebook']['account'] = $sns_content_json['facebook_account']; $sns_content['facebook']['footer'] = $sns_content_json['facebook_footer']; $sns_content['facebook']['pc_header'] = $sns_content_json['facebook_pc_header']; $sns_content['facebook']['sp_header'] = $sns_content_json['facebook_sp_header']; $sns_content['twitter']['account'] = $sns_content_json['twitter_account']; $sns_content['twitter']['footer'] = $sns_content_json['twitter_footer']; $sns_content['twitter']['pc_header'] = $sns_content_json['twitter_pc_header']; $sns_content['twitter']['sp_header'] = $sns_content_json['twitter_sp_header']; $sns_content['line']['account'] = $sns_content_json['line_account']; $sns_content['line']['footer'] = $sns_content_json['line_footer']; $sns_content['line']['pc_header'] = $sns_content_json['line_pc_header']; $sns_content['line']['sp_header'] = $sns_content_json['line_sp_header']; $sns_content['instagram']['account'] = $sns_content_json['instagram_account']; $sns_content['instagram']['footer'] = $sns_content_json['instagram_footer']; $sns_content['instagram']['pc_header'] = $sns_content_json['instagram_pc_header']; $sns_content['instagram']['sp_header'] = $sns_content_json['instagram_sp_header']; $sns_content['tiktok']['account'] = $sns_content_json['tiktok_account']; $sns_content['tiktok']['footer'] = $sns_content_json['tiktok_footer']; $sns_content['tiktok']['pc_header'] = $sns_content_json['tiktok_pc_header']; $sns_content['tiktok']['sp_header'] = $sns_content_json['tiktok_sp_header']; $sns_content['threads']['account'] = $sns_content_json['threads_account']; $sns_content['threads']['footer'] = $sns_content_json['threads_footer']; $sns_content['threads']['pc_header'] = $sns_content_json['threads_pc_header']; $sns_content['threads']['sp_header'] = $sns_content_json['threads_sp_header']; $sns_content['youtube']['account'] = $sns_content_json['youtube_account']; $sns_content['youtube']['footer'] = $sns_content_json['youtube_footer']; $sns_content['youtube']['pc_header'] = $sns_content_json['youtube_pc_header']; $sns_content['youtube']['sp_header'] = $sns_content_json['youtube_sp_header']; $sns_content['other1']['account'] = $sns_content_json['other1_account']; $sns_content['other1']['footer'] = $sns_content_json['other1_footer']; $sns_content['other1']['pc_header'] = $sns_content_json['other1_pc_header']; $sns_content['other1']['sp_header'] = $sns_content_json['other1_sp_header']; $sns_content['other1']['image'] = $sns_content_json['other1_image']; $sns_content['other2']['account'] = $sns_content_json['other2_account']; $sns_content['other2']['footer'] = $sns_content_json['other2_footer']; $sns_content['other2']['pc_header'] = $sns_content_json['other2_pc_header']; $sns_content['other2']['sp_header'] = $sns_content_json['other2_sp_header']; $sns_content['other2']['image'] = $sns_content_json['other2_image']; $sns_content['other3']['account'] = $sns_content_json['other3_account']; $sns_content['other3']['footer'] = $sns_content_json['other3_footer']; $sns_content['other3']['pc_header'] = $sns_content_json['other3_pc_header']; $sns_content['other3']['sp_header'] = $sns_content_json['other3_sp_header']; $sns_content['other3']['image'] = $sns_content_json['other3_image']; // foreach($sns_content as $key=>$val){ if($val['footer'] == 1){ $footer_display_flag = 1; } if($val['sp_header'] == 1){ $sp_header_others = 1; } } } $this->set('sns_content', $sns_content); $this->set('sp_header_others', $sp_header_others); $this->set('footer_display_flag', $footer_display_flag); //$data['newsetting'] = $newsetting; // if(!empty($company->domain)){ $data['site_url'] = 'https://'.$company->domain; }else{ if(SV_KIND2 == 'IPP3_1'){ $data['site_url'] = 'https://'.$company->subdomain.'.onerank-cms.com'; }elseif(SV_KIND2 == 'IPP3_2'){ $data['site_url'] = 'https://'.$company->subdomain.'.onerank-cms-2.com'; }elseif(SV_KIND2 == 'IPP3_3'){ $data['site_url'] = 'https://'.$company->subdomain.'.onerank-cms-3.com'; }elseif(SV_KIND2 == 'dev(AWS)'){ $data['site_url'] = 'https://'.$company->subdomain.'.onerank-hybrid-dev.com'; }elseif(SV_KIND2 == 'dev2(AWS)'){ $data['site_url'] = 'https://'.$company->subdomain.'.onerank-hybrid-dev2.com'; }elseif(SV_KIND2 == 'dev3(AWS)'){ $data['site_url'] = 'https://'.$company->subdomain.'.onerank-hybrid-dev3.com'; } } // if(!empty($data['setting']->breadcrumb_text)){ $breadcrumb_text = $data['setting']->breadcrumb_text; }else{ $breadcrumb_text = 'TOPページ'; } $contact_gallery_id = ''; $contact_recruit_id = ''; //slugの取得と整形 if(strpos($_SERVER['REQUEST_URI'], '?mode=preview') !== false){ $request_uri = strstr($_SERVER['REQUEST_URI'], '?', TRUE); $preview_mode = 'on'; //iframe }elseif(strpos($_SERVER['REQUEST_URI'], '?mode=iframe') !== false){ $request_uri = strstr($_SERVER['REQUEST_URI'], '?', TRUE); $iframe_mode = true; //iframe }elseif(strpos($_SERVER['REQUEST_URI'], '?gallery_id') !== false){ $request_uri = strstr($_SERVER['REQUEST_URI'], '?', TRUE); $contact_gallery_id = str_replace('gallery_id=', '', $_SERVER['QUERY_STRING']); //iframe }elseif(strpos($_SERVER['REQUEST_URI'], '?recruit_id') !== false){ $request_uri = strstr($_SERVER['REQUEST_URI'], '?', TRUE); $contact_recruit_id = str_replace('recruit_id=', '', $_SERVER['QUERY_STRING']); //HashTag /*}elseif(strpos($_SERVER['REQUEST_URI'], '#') !== false){ $request_uri = strstr($_SERVER['REQUEST_URI'], '#', TRUE); $hash_tag = strstr($_SERVER['REQUEST_URI'], '#'); $hash_tag = str_replace('#', '', $hash_tag);*/ //リダイレクト処理後に移動 // }elseif(strpos($_SERVER['REQUEST_URI'], '?') !== false){ // $request_uri = strstr($_SERVER['REQUEST_URI'], '?', TRUE); //iframe }elseif(strpos($_SERVER['REQUEST_URI'], '?preview') !== false){ $request_uri = strstr($_SERVER['REQUEST_URI'], '?', TRUE); $preview_id = str_replace('preview=', '', $_SERVER['QUERY_STRING']); $this->set('preview', 'preview'); }else{ $request_uri = $_SERVER['REQUEST_URI']; } /*if(empty($company_data)){ $company_data = new \stdClass; $company_data->id = ''; }*/ //末尾にスラッシュが付いていない場合の対応 if(substr($request_uri, -1) != '/'){ $request_uri = $request_uri.'/'; } //リダイレクト※※※キャッシュ設定 $request_uri_plus = $request_uri; $request_uri_plus = ltrim($request_uri_plus, '/'); $request_uri_plus = rtrim($request_uri_plus, '/'); //$request_uri_plus = urlencode($request_uri_plus); $request_uri_plus = str_replace('%2F', '/', $request_uri_plus); //追加:https://areus.backlog.jp/view/IPP3_CORRECTION-1693 if(strpos($request_uri_plus, '=') !== false){ $request_uri_plus = urlencode($request_uri_plus); } // $redirect = $this->Redirects->find() ->select(['Redirects.id', 'Redirects.slug', 'Redirects.slug_plus', 'Redirects.r_slug', 'Redirects.status_code']) ->where(['Redirects.company_id' => $company->id]) //->where(['Redirects.slug' => $slug]) //->where(['Redirects.slug_plus' => $slug]) ->where(['Redirects.slug' => $request_uri_plus]) ->where(['Redirects.delete_flag' => 0]) ->first(); // if(!empty($redirect)){ //TOPへのリダイレクト if(empty($redirect->r_slug)){ return $this->redirect('/', $redirect->status_code); //TOP以外へのリダイレクト }else{ //リダイレクト先にさらにリダイレクトがあるか確認 $tmp_redirect = $this->Redirects->find() ->select(['Redirects.id', 'Redirects.slug', 'Redirects.r_slug', 'Redirects.status_code']) ->where(['Redirects.company_id' => $company->id]) //->where(['Redirects.slug' => $redirect->r_slug]) //->where(['Redirects.slug_plus' => $redirect->r_slug]) ->where(['Redirects.slug' => $redirect->r_slug]) ->where(['Redirects.delete_flag' => 0]) ->first(); //2段階以上のリダイレクトの場合、処理を中止してTOPに強制リダイレクト if(!empty($tmp_redirect)){ return $this->redirect('/', '301'); }else{ return $this->redirect('/'.$redirect->r_slug.'/', $redirect->status_code); } } } //リダイレクト処理に問題がある為、上から移動 if(strpos($_SERVER['REQUEST_URI'], '?') !== false){ $request_uri = strstr($_SERVER['REQUEST_URI'], '?', TRUE); } $request_uri_array = explode('/', $request_uri); $request_uri_array = array_filter($request_uri_array, "strlen"); //ブログのカテゴリやタグなどのアーカイブ系(固定スラッグ)や、ページネーション系の為の処理 if(!empty($request_uri_array)){ $fixed_slug_array = ['archive','dictionary','category','tag']; $fixed_slug_array2 = ['gallery_archive','comparison_archive']; $reverse_request_uri_array = array_reverse($request_uri_array); //末尾に数字が付くか付かないか if(is_numeric($reverse_request_uri_array[0])){ //数字のみのslugかどうか判別 $slug_check = $this->Newpages->find() ->where(['Newpages.company_id' => $company->id]) ->where(['Newpages.slug' => $reverse_request_uri_array[0]]) ->where(['Newpages.delete_flag' => 0]) ->first(); //form_conf・form_sendのIDの場合の処理 if((isset($reverse_request_uri_array[1]) && $reverse_request_uri_array[1] == 'form_conf') || (isset($reverse_request_uri_array[1]) && $reverse_request_uri_array[1] == 'form_send')){ $fixed_slug = $reverse_request_uri_array[1]; if(isset($reverse_request_uri_array[2])){ //$slug = $reverse_request_uri_array[2]; $slug_plus = '/'.$reverse_request_uri_array[2].'/'; }else{ $slug = ''; $slug_plus = '/'; } if(isset($reverse_request_uri_array[3])){ $slug_plus = '/'.$reverse_request_uri_array[3].$slug_plus; } if(isset($reverse_request_uri_array[4])){ $slug_plus = '/'.$reverse_request_uri_array[4].$slug_plus; $slug_mode = 'slug'; $fixed_slug2 = 'detail'; $slug = $reverse_request_uri_array[2]; } $form_block_id = $reverse_request_uri_array[0]; //ブログ・新着情報、年月アーカイブ(ページネーション無し)/blog/archive/2019/04/ }elseif(isset($reverse_request_uri_array[2]) && $reverse_request_uri_array[2] == 'archive'){ $slug = $reverse_request_uri_array[3]; if(isset($reverse_request_uri_array[4]) && !empty($reverse_request_uri_array[4])){ $slug = $reverse_request_uri_array[4].'/'.$slug; } if(isset($reverse_request_uri_array[5]) && !empty($reverse_request_uri_array[5])){ $slug = $reverse_request_uri_array[5].'/'.$slug; } $fixed_slug = 'archive'; $archive_year = $reverse_request_uri_array[1]; $archive_month = $reverse_request_uri_array[0]; $page_num = ''; //※※※ $slug_plus = '/'.$slug.'/'; //ブログ・新着情報、年月アーカイブ(ページネーション有り)/blog/archive/2019/04/2/ }elseif(isset($reverse_request_uri_array[3]) && $reverse_request_uri_array[3] == 'archive'){ $slug = $reverse_request_uri_array[4]; if(isset($reverse_request_uri_array[5]) && !empty($reverse_request_uri_array[5])){ $slug = $reverse_request_uri_array[5].'/'.$slug; } if(isset($reverse_request_uri_array[6]) && !empty($reverse_request_uri_array[6])){ $slug = $reverse_request_uri_array[6].'/'.$slug; } $fixed_slug = 'archive'; $archive_year = $reverse_request_uri_array[2]; $archive_month = $reverse_request_uri_array[1]; $page_num = $reverse_request_uri_array[0]; //※※※ $slug_plus = '/'.$slug.'/'; //用語一覧のページネーション }elseif(isset($reverse_request_uri_array[2]) && $reverse_request_uri_array[2] == 'dictionary'){ $page_num = $reverse_request_uri_array[0]; $fixed_slug = $reverse_request_uri_array[1]; //TOPページ以外の場合 $slug = $reverse_request_uri_array[2]; //ブログ・新着情報記事 }elseif(!empty($slug_check) && isset($reverse_request_uri_array[1]) && $reverse_request_uri_array[1] == 'detail'){ $slug = $reverse_request_uri_array[0]; $slug_mode = 'slug'; //slugが数字の固定ページ }elseif(!empty($slug_check)){ //$slug_plus = $reverse_request_uri_array[0]; $slug_plus = $slug_check->slug_plus; //新ギャラリーの詳細の場合を追加 }elseif(isset($reverse_request_uri_array[1]) && $reverse_request_uri_array[1] == 'detail'){ $tag_category = $reverse_request_uri_array[0]; $fixed_slug = $reverse_request_uri_array[1]; $slug = $reverse_request_uri_array[2]; //https://hpcms.net/2/ の様な形式なのでありえない }elseif(!isset($reverse_request_uri_array[1])){ //return $this->redirect('/', '301'); $slug = 'cccccccccccccccccccccccccccccccccccccccccccccc'; }else{ $page_num = $reverse_request_uri_array[0]; //https://hpcms.net/2/ の様な形式なのでありえない if(!isset($reverse_request_uri_array[1])){ $fixed_slug = ''; $slug = 'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa'; }else{ if(in_array($reverse_request_uri_array[1], $fixed_slug_array)){ $fixed_slug = $reverse_request_uri_array[1]; $slug = $reverse_request_uri_array[2]; if(isset($reverse_request_uri_array[3]) && !empty($reverse_request_uri_array[3])){ $slug = $reverse_request_uri_array[3].'/'.$slug; } if(isset($reverse_request_uri_array[4]) && !empty($reverse_request_uri_array[4])){ $slug = $reverse_request_uri_array[4].'/'.$slug; } $slug_plus = '/'.$reverse_request_uri_array[2].'/'; }elseif(isset($reverse_request_uri_array[2]) && in_array($reverse_request_uri_array[2], $fixed_slug_array)){ $tag_category = $reverse_request_uri_array[1]; $fixed_slug = $reverse_request_uri_array[2]; $slug = $reverse_request_uri_array[3]; $slug_plus = '/'.$reverse_request_uri_array[3].'/'; if(isset($reverse_request_uri_array[4]) && !empty($reverse_request_uri_array[4])){ $slug_plus = '/'.$reverse_request_uri_array[4].'/'.$slug.'/'; } if(isset($reverse_request_uri_array[5]) && !empty($reverse_request_uri_array[5])){ $slug_plus = '/'.$reverse_request_uri_array[5].'/'.$reverse_request_uri_array[4].'/'.$slug.'/'; } }elseif(isset($reverse_request_uri_array[2]) && in_array($reverse_request_uri_array[2], $fixed_slug_array2)){ $page_num = $reverse_request_uri_array[0]; $fixed_slug = $reverse_request_uri_array[2]; $slug = $reverse_request_uri_array[1]; $slug_plus = '/'.$reverse_request_uri_array[1].'/'; }elseif(isset($reverse_request_uri_array[1]) && in_array($reverse_request_uri_array[1], $fixed_slug_array2)){ $page_num = 1; $fixed_slug = $reverse_request_uri_array[1]; $slug = $reverse_request_uri_array[0]; $slug_plus = '/'.$reverse_request_uri_array[0].'/'; }else{ $page_num = $reverse_request_uri_array[0]; $slug = $reverse_request_uri_array[1]; $slug_plus = '/'.$reverse_request_uri_array[1].'/'; if(isset($reverse_request_uri_array[2])){ $slug_plus = '/'.$reverse_request_uri_array[2].$slug_plus; } if(isset($reverse_request_uri_array[3])){ $slug_plus = '/'.$reverse_request_uri_array[3].$slug_plus; } } } } }else{ if(isset($reverse_request_uri_array[0]) && in_array($reverse_request_uri_array[0], $fixed_slug_array2)){ return $this->redirect('/'.$reverse_request_uri_array[0].'/all/', '301'); } if(in_array($reverse_request_uri_array[0], $fixed_slug_array)){ $page_num = 1; $fixed_slug = $reverse_request_uri_array[0]; //TOPページ以外の場合 if(isset($reverse_request_uri_array[1])){ $slug = $reverse_request_uri_array[1]; //TOPページの場合 }else{ $slug_plus = '/'; } //$slug = $reverse_request_uri_array[1]; }elseif(isset($reverse_request_uri_array[1]) && in_array($reverse_request_uri_array[1], $fixed_slug_array)){ $page_num = 1; $tag_category = $reverse_request_uri_array[0]; $fixed_slug = $reverse_request_uri_array[1]; $slug = $reverse_request_uri_array[2]; if(isset($reverse_request_uri_array[3]) && !empty($reverse_request_uri_array[3])){ $slug = $reverse_request_uri_array[3].'/'.$slug; } if(isset($reverse_request_uri_array[4]) && !empty($reverse_request_uri_array[4])){ $slug = $reverse_request_uri_array[4].'/'.$slug; } $slug_plus = '/'.$slug.'/'; // }elseif(isset($reverse_request_uri_array[1]) && in_array($reverse_request_uri_array[1], $fixed_slug_array2)){ $page_num = 1; $fixed_slug = $reverse_request_uri_array[1]; $slug = $reverse_request_uri_array[0]; //gallery_archiveやcomparison_archiveでパラメータが付いていない=全件表示の場合の処理 }elseif(isset($reverse_request_uri_array[0]) && in_array($reverse_request_uri_array[0], $fixed_slug_array2)){ $page_num = 1; $fixed_slug = $reverse_request_uri_array[0]; $slug = ''; }else{ $slug = $reverse_request_uri_array[0]; $slug_plus = $request_uri; } } //固定スラッグがdetailの場合の処理 if(isset($reverse_request_uri_array[1]) && $reverse_request_uri_array[1] == 'detail'){ //辞書の詳細ページの場合 if(isset($reverse_request_uri_array[2]) && $reverse_request_uri_array[2] == 'dictionary'){ $page_mode = 'dictionary'; $fixed_slug = 'detail'; $slug = $reverse_request_uri_array[0]; //ブログや新着情報、特集の詳細ページの場合 }else{ if($_SERVER['REMOTE_ADDR'] == '202.12.244.62'){ //var_dump('aaa'); } $fixed_slug = 'detail'; //$slug = $reverse_request_uri_array[0]; $slug_mode = 'slug'; $slug_plus = $request_uri; } } //固定スラッグがgallery_archive,comparison_archive if($fixed_slug == 'gallery_archive' || $slug == 'gallery_archive'){ $page_mode = 'gallery_archive'; }elseif($fixed_slug == 'comparison_archive' || $slug == 'comparison_archive'){ $page_mode = 'comparison_archive'; }elseif($fixed_slug == 'tag'){ $page_mode = 'tag'; } //固定スラッグがcategoryやtagの場合、slugの内容を書き換え /*if($fixed_slug == 'category' || $fixed_slug == 'tag'){ $slug_name = $slug; }*/ }else{ $slug = ''; $slug_plus = '/'; } /*if($_SERVER['REMOTE_ADDR'] == '110.74.59.1'){ var_dump($page_num); var_dump($tag_category); var_dump($fixed_slug); var_dump($slug); var_dump($slug_plus); var_dump($archive_year); var_dump($archive_month); }*/ // $data['slug_plus'] = $slug_plus; //問い合わせフォームのPOSTがあった場合の処理 $data['form_error_message'] = []; if($this->request->is('post')){ $contact_id = ''; $form_recruit_id = ''; $form_block_id = ''; $form_url = ''; if(isset($this->request->data['contact_id'])){ $contact_id = $this->request->data['contact_id']; } if(isset($this->request->data['form_recruit_id'])){ $form_recruit_id = $this->request->data['form_recruit_id']; } if(isset($this->request->data['block_id'])){ $form_block_id = $this->request->data['block_id']; } if(isset($this->request->data['form_url'])){ $form_url = $this->request->data['form_url']; } //unset($this->request->data['contact_id']); // $contact['parent'] = $this->Contacts->find() ->where(['Contacts.id' => $contact_id]) ->where(['Contacts.company_id' => $company->id]) ->where(['Contacts.delete_flag' => 0]) ->first(); $contact_details = $this->ContactDetails->find() //->where(['ContactDetails.company_id' => $company_id]) ->where(['ContactDetails.contact_id' => $contact_id]) ->where(['ContactDetails.delete_flag' => 0]) ->order(['ContactDetails.sort' => 'ASC']) ->all(); //form_recruit_idがある場合、リクルート情報を取得 $form_recruit_name = ''; if(!empty($form_recruit_id)){ $form_recruit = $this->Recruits->find() ->where(['Recruits.id' => $form_recruit_id]) ->where(['Recruits.company_id' => $company->id]) ->where(['Recruits.delete_flag' => 0]) ->first(); if(!empty($form_recruit)){ $form_recruit_name = $form_recruit->title; } } //確認画面からのPOST if($fixed_slug == 'form_conf'){ //除外IPか確認 if(strpos($contact['parent']->rejection_ip, $_SERVER['REMOTE_ADDR']) === false){ //$this->log($contact['parent']->form_sender_server, "debug"); // if(!empty($contact['parent']['grv3_sitekey']) && !empty($contact['parent']['grv3_secretkey'])){ if($contact['parent']['recaptcha_flag'] == 1){ //$recaptchaToken = $tmp_form_data['form_data']['recaptchaToken']; $recaptchaToken = $this->request->data['recaptchaToken']; $params = array( 'secret' => $contact['parent']['grv3_secretkey'], 'response' => $recaptchaToken, ); //$url = 'https://recaptchaenterprise.googleapis.com/v1/projects'; $url = 'https://recaptchaenterprise.googleapis.com/v1/projects/'.$contact['parent']['recaptcha_project_id'].'/assessments?key='.$contact['parent']['grv3_secretkey']; //$url .= http_build_query($params); $jsonData = '{"event":{ "token": "'.$recaptchaToken.'", "siteKey": "'.$contact['parent']['grv3_sitekey'].'", "userAgent": "'.$_SERVER['HTTP_USER_AGENT'].'", "userIpAddress": "'.$_SERVER['REMOTE_ADDR'].'", "ja4": "JA4", "expectedAction": "USER_ACTION" }}'; $headerData = array( "Content-length: ".strlen($jsonData), "Content-Type: application/json; charset=UTF-8", ); $ch = curl_init(); curl_setopt($ch, CURLOPT_HTTPHEADER, $headerData); curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'POST'); curl_setopt($ch, CURLOPT_POSTFIELDS, $jsonData); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_URL,$url); $response = curl_exec($ch); curl_close($ch); /*$ch = curl_init(); curl_setopt( $ch, CURLOPT_URL, $url ); curl_setopt( $ch, CURLOPT_HEADER, false ); curl_setopt( $ch, CURLOPT_RETURNTRANSFER, true ); curl_setopt( $ch, CURLOPT_TIMEOUT, 120 ); $response = curl_exec( $ch ); curl_close( $ch );*/ //$this->log('20250603:'.$response, "debug"); $verify = json_decode($response); if($verify->tokenProperties->valid) { //var_dump('true'); } else { //var_dump('false'); //return $this->redirect('/', '301'); $contact_redirect_url = explode('form_conf', $_SERVER['REQUEST_URI']); return $this->redirect($contact_redirect_url[0], '301'); } }else{ //$recaptchaToken = $tmp_form_data['form_data']['recaptchaToken']; $recaptchaToken = $this->request->data['recaptchaToken']; $params = array( 'secret' => $contact['parent']['grv3_secretkey'], 'response' => $recaptchaToken, ); $url = 'https://www.google.com/recaptcha/api/siteverify?'; $url .= http_build_query($params); $ch = curl_init(); curl_setopt( $ch, CURLOPT_URL, $url ); curl_setopt( $ch, CURLOPT_HEADER, false ); curl_setopt( $ch, CURLOPT_RETURNTRANSFER, true ); curl_setopt( $ch, CURLOPT_TIMEOUT, 120 ); $response = curl_exec( $ch ); curl_close( $ch ); $verify = json_decode($response); if($verify->success) { //var_dump('true'); } else { //var_dump('false'); //return $this->redirect('/', '301'); $contact_redirect_url = explode('form_conf', $_SERVER['REQUEST_URI']); return $this->redirect($contact_redirect_url[0], '301'); } } } // $file_flag = 0; $file_arrays = []; //SMTPサーバー関連の設定が済んでいる場合 if(!empty($contact['parent']->form_sender_server) && !empty($contact['parent']->form_sender_account) && !empty($contact['parent']->form_sender_password) && !empty($contact['parent']->form_sender_port)){ // require LIB.'PHPMailer/src/PHPMailer.php'; require LIB.'PHPMailer/src/SMTP.php'; require LIB.'PHPMailer/src/POP3.php'; require LIB.'PHPMailer/src/Exception.php'; require LIB.'PHPMailer/src/OAuth.php'; require LIB.'PHPMailer/language/phpmailer.lang-ja.php'; // //use PHPMailer\PHPMailer\PHPMailer; //use PHPMailer\PHPMailer\Exception; mb_language("japanese"); mb_internal_encoding("UTF-8"); // $user_mail = ''; foreach($contact_details as $contact_detail){ if($contact_detail->type == 'mail'){ $user_mail = $this->request->data[$contact_detail->id]; } } //メッセージ $msg2 = "\n\n"; // if(isset($this->request->data['contact_gallery_id']) && !empty($this->request->data['contact_gallery_id'])){ /*$contact_gallery_id = $this->request->data['contact_gallery_id']; $contact_gallery_url = $this->request->data['contact_gallery_url']; $contact_gallery_name = $this->request->data['contact_gallery_name']; $contact_gallery_content = $this->request->data['contact_gallery_content'];*/ $msg2 .= "■URL\n".$this->request->data['contact_gallery_url']."\n\n"; $msg2 .= "■タイトル\n".$this->request->data['contact_gallery_name']."\n\n"; $msg2 .= "■説明\n".$this->request->data['contact_gallery_content']."\n\n"; } // if(isset($this->request->data['contact_recruit_id']) && !empty($this->request->data['contact_recruit_id'])){ $msg2 .= "■URL\n".$this->request->data['contact_recruit_url']."\n\n"; $msg2 .= "■タイトル\n".$this->request->data['contact_recruit_name']."\n\n"; $msg2 .= "■説明\n".$this->request->data['contact_recruit_content']."\n\n"; } foreach($contact_details as $contact_detail){ //空欄項目の取り扱い if($contact['parent']->blank_flag == 1 && isset($this->request->data[$contact_detail->id]) && empty($this->request->data[$contact_detail->id])){ }else{ if($contact_detail->type == 'checkbox'){ if(isset($this->request->data[$contact_detail->id]) && !empty($this->request->data[$contact_detail->id])){ $msg2 .= "■".$contact_detail->name."\n"; $msg2 .= "".implode('、',$this->request->data[$contact_detail->id])."\n\n"; } }elseif($contact_detail->type == 'image' && !empty($this->request->data[$contact_detail->id.'_tmp_name'])){ //$msg2 .= "■".$contact_detail->name."\n"; $tmp_file_array = []; $tmp_file_array['tmp_name'] = $this->request->data[$contact_detail->id.'_tmp_name']; $tmp_file_array['name'] = $this->request->data[$contact_detail->id.'_name']; $tmp_file_array['tmp_file_name'] = $this->request->data[$contact_detail->id.'_tmp_file_name']; $tmp_file_array['type'] = $this->request->data[$contact_detail->id.'_type']; $tmp_file_array['subdomain'] = $this->request->data[$contact_detail->id.'_subdomain']; $file_arrays[] = $tmp_file_array; $file_flag = 1; }else{ $msg2 .= "■".$contact_detail->name."\n"; $msg2 .= "".$this->request->data[$contact_detail->id]."\n\n"; } } } //$msg2 .= "\n"; //$msg2 .= $contact['parent']->user_sign; //POP before SMTPの設定内容が全て埋まっている場合 if(!empty($contact['parent']->form_receiver_server) && !empty($contact['parent']->form_receiver_account) && !empty($contact['parent']->form_receiver_password) && !empty($contact['parent']->form_receiver_port)){ $pop = new POP3(); //$pop->Authorise('pop.inheritance.co.jp', 110, 10, 'contact@inheritance.co.jp', 'Ct0878ih', 1); $pop->authorise($contact['parent']->form_receiver_server, $contact['parent']->form_receiver_port, 10, $contact['parent']->form_receiver_account, $contact['parent']->form_receiver_password, 0); //$pop = POP3::popBeforeSmtp($form_receiver_server, $form_receiver_port, 30, $form_receiver_account, $form_receiver_password, 1); } //SMTPの設定 $mailer = new PHPMailer();//インスタンス生成 $mailer->IsSMTP();//SMTPを作成 $mailer->Host = $contact['parent']->form_sender_server; $mailer->CharSet = 'utf-8'; $mailer->SMTPAuth = true; $mailer->Username = $contact['parent']->form_sender_account; $mailer->Password = $contact['parent']->form_sender_password; //$mailer->SMTPSecure = 'tls'; //POP before SMTPの設定内容が全て埋まっている場合 if(!empty($contact['parent']->form_receiver_server) && !empty($contact['parent']->form_receiver_account) && !empty($contact['parent']->form_receiver_password) && !empty($contact['parent']->form_receiver_port)){ // //$mailer->SMTPAuth = true; $mailer->SMTPSecure = false; $mailer->SMTPAutoTLS = false; }else{ // //$mailer->SMTPAuth = true; } // if($contact['parent']->form_sender_server == 'smtp.gmail.com' || $contact['parent']->form_sender_server == 'smtp.office365.com'){ $mailer->SMTPSecure = 'tls'; $mailer->Port = 587; $mailer->SMTPOptions = [ 'ssl' => [ 'verify_peer' => false ,'verify_peer_name' => false ,'allow_self_signed' => true ] ]; }else{ $mailer->Port = $contact['parent']->form_sender_port; } //$mailer->SMTPDebug = 2; //メール本体・ユーザーへメール送信 if(!empty($user_mail)){ $mailer->AddAddress($user_mail); // To宛先 $mailer->From = $contact['parent']->from_mail; //差出人の設定 //$mailer->FromName = mb_convert_encoding($contact['parent']->from_mail,"UTF-8","AUTO"); $mailer->FromName = mb_convert_encoding($contact['parent']->from_name,"UTF-8","AUTO"); $mailer->Subject = mb_convert_encoding($contact['parent']->user_subject,"UTF-8","AUTO");//件名の設定 //$message = mb_strimwidth($page->content, 0, 200, "...", "UTF-8");//メール本文 $msg1 = ''; $msg1 .= $contact['parent']->user_content; // $msg = $msg1.$msg2."\n".$contact['parent']->user_sign; $msg = str_replace("\r", "", $msg); $mailer->Body = mb_convert_encoding($msg,"UTF-8","AUTO");//メッセージ本体 //$this->log($file_flag, "debug"); //添付ファイルがある場合 $AddAttachment = []; if($file_flag == 1){ // if(SV_KIND2 == 'IPP3_1'){ $attachment_url = 'https://onerank-cms.com'; }elseif(SV_KIND2 == 'IPP3_2'){ $attachment_url = 'https://onerank-cms-2.com'; }elseif(SV_KIND2 == 'IPP3_3'){ $attachment_url = 'https://onerank-cms-3.com'; }elseif(SV_KIND2 == 'dev(AWS)'){ $attachment_url = 'https://onerank-hybrid-dev.com'; }elseif(SV_KIND2 == 'dev2(AWS)'){ $attachment_url = 'https://onerank-hybrid-dev2.com'; }elseif(SV_KIND2 == 'dev3(AWS)'){ $attachment_url = 'https://onerank-hybrid-dev3.com'; }else{ $attachment_url = 'https://onerank-cms-dev.com'; } // foreach($file_arrays as $file_array){ if($file_array['type'] == 'application/pdf'){ //ディレクトリが存在するかチェック /*if(!file_exists('/var/www/html/application/webroot/common/upload_data/'.$file_array['subdomain'].'/file')){ exec('sudo mkdir /var/www/html/application/webroot/common/upload_data/'.$file_array['subdomain'].'/file'); exec('sudo chmod 777 /var/www/html/application/webroot/common/upload_data/'.$file_array['subdomain'].'/file'); }*/ $mailer->AddAttachment("/var/www/html/application/webroot/common/upload_data/".$file_array['subdomain']."/file/".$file_array['tmp_file_name'], $file_array['tmp_file_name'], 'base64', 'application/pdf'); $tmp_AddAttachment = []; $tmp_AddAttachment[0] = $file_array['type']; $tmp_AddAttachment[1] = $attachment_url."/common/upload_data/".$file_array['subdomain']."/file/".$file_array['tmp_file_name']; $tmp_AddAttachment[2] = $file_array['tmp_file_name']; //$tmp_AddAttachment[3] = 'base64'; $AddAttachment[] = $tmp_AddAttachment; }else{ $mailer->AddAttachment("/var/www/html/application/webroot/common/upload_data/".$file_array['subdomain']."/image/".$file_array['tmp_file_name']); $tmp_AddAttachment = []; $tmp_AddAttachment[0] = $file_array['type']; $tmp_AddAttachment[1] = $attachment_url."/common/upload_data/".$file_array['subdomain']."/image/".$file_array['tmp_file_name']; $tmp_AddAttachment[2] = $file_array['tmp_file_name']; $AddAttachment[] = $tmp_AddAttachment; } } } //送信処理 //if($_SERVER['REMOTE_ADDR'] == '202.12.244.62'){ if($company->server_kind == 1){ $headers = [ 'Content-Type: application/json', 'Accept-Charset: UTF-8', ]; $post_data = []; $post_data['Host'] = $contact['parent']->form_sender_server; $post_data['CharSet'] = 'utf-8'; $post_data['SMTPAuth'] = true; $post_data['Username'] = $contact['parent']->form_sender_account; $post_data['Password'] = $contact['parent']->form_sender_password; $post_data['SMTPSecure'] = false; $post_data['SMTPAutoTLS'] = false; $post_data['Port'] = $contact['parent']->form_sender_port; //$mailer->AddAddress = $post_data['AddAddress']; $post_data['todata'][] = $user_mail; $post_data['to'] = $user_mail; $post_data['From'] = $contact['parent']->from_mail; //$post_data['FromName'] = mb_convert_encoding($contact['parent']->from_mail,"UTF-8","AUTO"); $post_data['FromName'] = mb_convert_encoding($contact['parent']->from_name,"UTF-8","AUTO"); $post_data['addReplyTo'] = ''; $post_data['Subject'] = mb_convert_encoding($contact['parent']->user_subject,"UTF-8","AUTO"); $post_data['Body'] = mb_convert_encoding($msg,"UTF-8","AUTO"); $post_data['AddAttachment'] = $AddAttachment; $post_data['company_id'] = $company->id; $post_data['REMOTE_ADDR'] = $_SERVER['REMOTE_ADDR']; $post_data_json = json_encode($post_data, JSON_UNESCAPED_UNICODE); $mailer_json = json_encode($mailer, JSON_UNESCAPED_UNICODE); //if($company->id == 1453){ $hoge = $this->Mail->send($post_data); $this->log('250404:'.json_encode($hoge, JSON_UNESCAPED_UNICODE), "debug"); /*}else{ $ch = curl_init(); // curl_setopt($ch, CURLOPT_URL, 'https://onerank-cms-2.com/mails/ipp-new-mail-send/'); //curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST"); // メソッド指定 Ver. POST curl_setopt($ch, CURLOPT_POST, TRUE); curl_setopt($ch, CURLOPT_HTTPHEADER, $headers); //curl_setopt($ch, CURLOPT_POSTFIELDS, $post_data); // パラメータをセット curl_setopt($ch, CURLOPT_POSTFIELDS, $post_data_json); // パラメータをセット //curl_setopt($ch, CURLOPT_POSTFIELDS, $mailer); // パラメータをセット curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); // 証明書の検証を行わない curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); // レスポンスを文字列で受け取る // $response_json = curl_exec($ch); }*/ //$response = json_decode($response_json, true); //$post_http_info = curl_getinfo($ch); /*if($_SERVER['REMOTE_ADDR'] == '202.12.244.62'){ var_dump($post_data_json); var_dump($response_json); var_dump($post_http_info); exit(); }*/ //curl_close($ch); }else{ if($mailer->Send()){ //$this->log('success', "debug"); }else{ //$this->log($mailer, "debug"); //$this->log('error', "debug"); //$this->log($mailer->ErrorInfo, "debug"); //echo "送信に失敗しました" . $mailer->ErrorInfo; } } } //POP before SMTPの設定内容が全て埋まっている場合 if(!empty($contact['parent']->form_receiver_server) && !empty($contact['parent']->form_receiver_account) && !empty($contact['parent']->form_receiver_password) && !empty($contact['parent']->form_receiver_port)){ $pop = new POP3(); //$pop->Authorise('pop.inheritance.co.jp', 110, 10, 'contact@inheritance.co.jp', 'Ct0878ih', 1); $pop->authorise($contact['parent']->form_receiver_server, $contact['parent']->form_receiver_port, 10, $contact['parent']->form_receiver_account, $contact['parent']->form_receiver_password, 0); //$pop = POP3::popBeforeSmtp($form_receiver_server, $form_receiver_port, 30, $form_receiver_account, $form_receiver_password, 1); } //SMTPの設定 $mailer = new PHPMailer();//インスタンス生成 $mailer->IsSMTP();//SMTPを作成 $mailer->Host = $contact['parent']->form_sender_server; $mailer->CharSet = 'utf-8'; $mailer->SMTPAuth = true; $mailer->Username = $contact['parent']->form_sender_account; $mailer->Password = $contact['parent']->form_sender_password; //$mailer->SMTPSecure = 'tls'; //POP before SMTPの設定内容が全て埋まっている場合 if(!empty($contact['parent']->form_receiver_server) && !empty($contact['parent']->form_receiver_account) && !empty($contact['parent']->form_receiver_password) && !empty($contact['parent']->form_receiver_port)){ // //$mailer->SMTPAuth = true; $mailer->SMTPSecure = false; $mailer->SMTPAutoTLS = false; }else{ // //$mailer->SMTPAuth = true; } // if($contact['parent']->form_sender_server == 'smtp.gmail.com' || $contact['parent']->form_sender_server == 'smtp.office365.com'){ $mailer->SMTPSecure = 'tls'; $mailer->Port = 587; $mailer->SMTPOptions = [ 'ssl' => [ 'verify_peer' => false ,'verify_peer_name' => false ,'allow_self_signed' => true ] ]; }else{ $mailer->Port = $contact['parent']->form_sender_port; } //$mailer->SMTPDebug = 2; //メール本体・管理者へメール送信 if(strpos($contact['parent']->reception_mail, ',') !== false){ $reception_mail_array = explode(',', $contact['parent']->reception_mail); foreach($reception_mail_array as $key=>$val){ $mailer->AddAddress($val); // To宛先 } }else{ $mailer->AddAddress($contact['parent']->reception_mail); // To宛先 } $mailer->From = $contact['parent']->from_mail; //差出人の設定 //$mailer->FromName = mb_convert_encoding($contact['parent']->from_mail,"UTF-8","AUTO"); $mailer->FromName = mb_convert_encoding($contact['parent']->from_name,"UTF-8","AUTO"); //Reply-To if(!empty($user_mail) && $contact['parent']->reply_flag == 1){ $mailer->addReplyTo($user_mail, $user_mail); } // $mailer->Subject = mb_convert_encoding($contact['parent']->admin_subject,"UTF-8","AUTO");//件名の設定 //$message = mb_strimwidth($page->content, 0, 200, "...", "UTF-8");//メール本文 $msg3 = ''; $msg3 .= $contact['parent']->admin_content; $msg3 .= "\n\n"; // if(!empty($form_recruit_name)){ $msg4 .= "■参照元の求人\n"; $msg4 .= " ".$form_recruit_name."\n"; $msg3 = $msg3.$msg4; } // $msg = $msg3.$msg2; $msg = $msg."\n\n(SMTP経由)"; $msg = str_replace("\r", "", $msg); $mailer->Body = mb_convert_encoding($msg,"UTF-8","AUTO");//メッセージ本体 //添付ファイルがある場合 $AddAttachment = []; if($file_flag == 1){ // if(SV_KIND2 == 'IPP3_1'){ $attachment_url = 'https://onerank-cms.com'; }elseif(SV_KIND2 == 'IPP3_2'){ $attachment_url = 'https://onerank-cms-2.com'; }elseif(SV_KIND2 == 'IPP3_3'){ $attachment_url = 'https://onerank-cms-3.com'; }elseif(SV_KIND2 == 'dev(AWS)'){ $attachment_url = 'https://onerank-hybrid-dev.com'; }elseif(SV_KIND2 == 'dev2(AWS)'){ $attachment_url = 'https://onerank-hybrid-dev2.com'; }elseif(SV_KIND2 == 'dev3(AWS)'){ $attachment_url = 'https://onerank-hybrid-dev3.com'; }else{ $attachment_url = 'https://onerank-cms-dev.com'; } // foreach($file_arrays as $file_array){ if($file_array['type'] == 'application/pdf'){ //ディレクトリが存在するかチェック /*if(!file_exists('/var/www/html/application/webroot/common/upload_data/'.$file_array['subdomain'].'/file')){ exec('sudo mkdir /var/www/html/application/webroot/common/upload_data/'.$file_array['subdomain'].'/file'); exec('sudo chmod 777 /var/www/html/application/webroot/common/upload_data/'.$file_array['subdomain'].'/file'); }*/ $mailer->AddAttachment("/var/www/html/application/webroot/common/upload_data/".$file_array['subdomain']."/file/".$file_array['tmp_file_name'], $file_array['tmp_file_name'], 'base64', 'application/pdf'); $tmp_AddAttachment = []; $tmp_AddAttachment[0] = $file_array['type']; $tmp_AddAttachment[1] = $attachment_url."/common/upload_data/".$file_array['subdomain']."/file/".$file_array['tmp_file_name']; $tmp_AddAttachment[2] = $file_array['tmp_file_name']; //$tmp_AddAttachment[3] = 'base64'; $AddAttachment[] = $tmp_AddAttachment; }else{ $mailer->AddAttachment("/var/www/html/application/webroot/common/upload_data/".$file_array['subdomain']."/image/".$file_array['tmp_file_name']); $tmp_AddAttachment = []; $tmp_AddAttachment[0] = $file_array['type']; $tmp_AddAttachment[1] = $attachment_url."/common/upload_data/".$file_array['subdomain']."/image/".$file_array['tmp_file_name']; $tmp_AddAttachment[2] = $file_array['tmp_file_name']; $AddAttachment[] = $tmp_AddAttachment; } } } //送信処理 //if($_SERVER['REMOTE_ADDR'] == '202.12.244.62'){ if($company->server_kind == 1){ /*$headers = [ 'Content-Type: application/json', 'Accept-Charset: UTF-8', ];*/ $post_data = []; $post_data['Host'] = $contact['parent']->form_sender_server; $post_data['CharSet'] = 'utf-8'; $post_data['SMTPAuth'] = true; $post_data['Username'] = $contact['parent']->form_sender_account; $post_data['Password'] = $contact['parent']->form_sender_password; $post_data['SMTPSecure'] = false; $post_data['SMTPAutoTLS'] = false; $post_data['Port'] = $contact['parent']->form_sender_port; //$mailer->AddAddress = $post_data['AddAddress']; //メール本体・管理者へメール送信 if(strpos($contact['parent']->reception_mail, ',') !== false){ $reception_mail_array = explode(',', $contact['parent']->reception_mail); foreach($reception_mail_array as $key=>$val){ $post_data['todata'][] = $val; } }else{ $post_data['todata'][] = $contact['parent']->reception_mail; } $post_data['to'] = $contact['parent']->reception_mail; $post_data['From'] = $contact['parent']->from_mail; //$post_data['FromName'] = mb_convert_encoding($contact['parent']->from_mail,"UTF-8","AUTO"); $post_data['FromName'] = mb_convert_encoding($contact['parent']->from_name,"UTF-8","AUTO"); if(!empty($user_mail) && $contact['parent']->reply_flag == 1){ $post_data['addReplyTo'] = $user_mail; } $post_data['Subject'] = mb_convert_encoding($contact['parent']->admin_subject,"UTF-8","AUTO"); $post_data['Body'] = mb_convert_encoding($msg,"UTF-8","AUTO"); $post_data['AddAttachment'] = $AddAttachment; $post_data['company_id'] = $company->id; $post_data['REMOTE_ADDR'] = $_SERVER['REMOTE_ADDR']; $post_data_json = json_encode($post_data, JSON_UNESCAPED_UNICODE); $mailer_json = json_encode($mailer, JSON_UNESCAPED_UNICODE); //if($company->id == 1456){ $this->Mail->send($post_data); /*}else{ $ch = curl_init(); // curl_setopt($ch, CURLOPT_URL, 'https://onerank-cms-2.com/mails/ipp-new-mail-send/'); curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST"); // メソッド指定 Ver. POST curl_setopt($ch, CURLOPT_HTTPHEADER, $headers); //curl_setopt($ch, CURLOPT_POSTFIELDS, $post_data); // パラメータをセット curl_setopt($ch, CURLOPT_POSTFIELDS, $post_data_json); // パラメータをセット //curl_setopt($ch, CURLOPT_POSTFIELDS, $mailer); // パラメータをセット curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); // 証明書の検証を行わない curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); // レスポンスを文字列で受け取る // $response_json = curl_exec($ch); $response = json_decode($response_json, true); //$post_http_info = curl_getinfo($ch); curl_close($ch); }*/ }else{ if($mailer->Send()){ //$this->log('success', "debug"); }else{ //$this->log($mailer, "debug"); //$this->log('error', "debug"); //$this->log($mailer->ErrorInfo, "debug"); //echo "送信に失敗しました" . $mailer->ErrorInfo; } } // //$this->Cookie->delete('ipp_lambda_form'); //$session->delete('ipp_lambda_form'); //完了画面へリダイレクト //return $this->redirect($this->request->data['back_url'].'form_send/'); //return $this->redirect($this->request->data['back_url'].'form_send/#'.$form_block_id); //return $this->redirect($this->request->data['back_url'].'form_send/'.$form_block_id.'/#'.$form_block_id); //通常のsend_mail関数による送信 }else{ $user_mail = ''; foreach($contact_details as $contact_detail){ if($contact_detail->type == 'mail'){ $user_mail = $this->request->data[$contact_detail->id]; } } //メッセージ $base_msg = "\n\n"; // if(isset($this->request->data['contact_gallery_id']) && !empty($this->request->data['contact_gallery_id'])){ /*$contact_gallery_id = $this->request->data['contact_gallery_id']; $contact_gallery_url = $this->request->data['contact_gallery_url']; $contact_gallery_name = $this->request->data['contact_gallery_name']; $contact_gallery_content = $this->request->data['contact_gallery_content'];*/ $base_msg .= "■URL\n ".$this->request->data['contact_gallery_url']."\n\n"; $base_msg .= "■タイトル\n ".$this->request->data['contact_gallery_name']."\n\n"; $base_msg .= "■説明\n ".strip_tags($this->request->data['contact_gallery_content'])."\n\n"; } // if(isset($this->request->data['contact_recruit_id']) && !empty($this->request->data['contact_recruit_id'])){ $base_msg .= "■URL\n ".$this->request->data['contact_recruit_url']."\n\n"; $base_msg .= "■タイトル\n ".$this->request->data['contact_recruit_name']."\n\n"; $base_msg .= "■説明\n ".strip_tags($this->request->data['contact_recruit_content'])."\n\n"; } foreach($contact_details as $contact_detail){ //空欄項目の取り扱い if($contact['parent']->blank_flag == 1 && isset($this->request->data[$contact_detail->id]) && empty($this->request->data[$contact_detail->id])){ }else{ if($contact_detail->type == 'checkbox'){ if(isset($this->request->data[$contact_detail->id]) && !empty($this->request->data[$contact_detail->id])){ $base_msg .= "■".$contact_detail->name."\n"; $base_msg .= "".implode('、',$this->request->data[$contact_detail->id])."\n\n"; } }elseif($contact_detail->type == 'image' && !empty($this->request->data[$contact_detail->id.'_tmp_name'])){ $tmp_file_array = []; $tmp_file_array['tmp_name'] = $this->request->data[$contact_detail->id.'_tmp_name']; $tmp_file_array['name'] = $this->request->data[$contact_detail->id.'_name']; $tmp_file_array['tmp_file_name'] = $this->request->data[$contact_detail->id.'_tmp_file_name']; $tmp_file_array['type'] = $this->request->data[$contact_detail->id.'_type']; $tmp_file_array['subdomain'] = $this->request->data[$contact_detail->id.'_subdomain']; $file_arrays[] = $tmp_file_array; $file_flag = 1; }else{ $base_msg .= "■".$contact_detail->name."\n"; $base_msg .= "".$this->request->data[$contact_detail->id]."\n\n"; } } } //$base_msg .= "\n"; //$base_msg .= $contact['parent']->user_sign; //ユーザーへメール送信 if(!empty($user_mail)){ $to = $user_mail; $subject = $contact['parent']->user_subject; //$from = mb_encode_mimeheader(" (自動送信メール) ").'<'.$contact['parent']->from_mail'>'; $from = $contact['parent']->from_mail; //$header = "From: $from"; $user_content = ''; $user_content .= $contact['parent']->user_content; // $user_msg = $user_content.$base_msg."\n".$contact['parent']->user_sign; $user_msg = str_replace("\r", "", $user_msg); //mb_language("Japanese"); //mb_internal_encoding ("SJIS"); //$subject = mb_convert_encoding($subject, "SJIS", "auto"); //$user_msg = mb_convert_encoding($user_msg, "SJIS", "auto"); /*if(mb_send_mail($to, $subject, $user_msg, $header)){ $this->log('送信成功', 'debug'); } else { $this->log('送信失敗', 'debug'); echo "送信エラー\n"; }*/ mb_language("ja"); mb_internal_encoding("UTF-8"); // if($file_flag == 1){ // ヘッダー設定 $header = ''; $header .= "Content-Type: multipart/mixed;boundary=\"__BOUNDARY__\"\n"; $header .= "Return-Path: " . $from . " \n"; $header .= "From: " . $from ." \n"; $header .= "Sender: " . $from ." \n"; $header .= "Reply-To: " . $from . " \n"; $header .= "Organization: " . $from . " \n"; $header .= "X-Sender: " . $from . " \n"; $header .= "X-Priority: 3 \n"; // テキストメッセージを記述 $body = "--__BOUNDARY__\n"; $body .= "Content-Type: text/plain; charset=\"ISO-2022-JP\"\n\n"; $body .= $user_msg . "\n"; $body .= "--__BOUNDARY__\n"; // ファイルを添付 foreach($file_arrays as $file_array){ //$body .= "Content-Type: application/octet-stream; name=\"{$file_array['name']}\"\n"; //$body .= "Content-Disposition: attachment; filename=\"{$file_array['name']}\"\n"; $body .= "Content-Type: application/octet-stream; name=\"{$file_array['tmp_file_name']}\"\n"; $body .= "Content-Disposition: attachment; filename=\"{$file_array['tmp_file_name']}\"\n"; $body .= "Content-Transfer-Encoding: base64\n"; $body .= "\n"; if($file_array['type'] == 'application/pdf'){ //ディレクトリが存在するかチェック /*if(!file_exists('/var/www/html/application/webroot/common/upload_data/'.$file_array['subdomain'].'/file')){ exec('sudo mkdir /var/www/html/application/webroot/common/upload_data/'.$file_array['subdomain'].'/file'); exec('sudo chmod 777 /var/www/html/application/webroot/common/upload_data/'.$file_array['subdomain'].'/file'); }*/ $body .= chunk_split(base64_encode(file_get_contents("/var/www/html/application/webroot/common/upload_data/".$file_array['subdomain']."/file/".$file_array['tmp_file_name']))); }else{ $body .= chunk_split(base64_encode(file_get_contents("/var/www/html/application/webroot/common/upload_data/".$file_array['subdomain']."/image/".$file_array['tmp_file_name']))); } $body .= "--__BOUNDARY__\n"; } if(mb_send_mail($to, $subject, $body, $header)){ } else { echo "送信エラー\n"; } }else{ $header = "From: $from"; $subject_sjis = mb_convert_encoding($subject, "SJIS", "auto"); $msg_sjis = mb_convert_encoding($user_msg, "SJIS", "auto"); if(mb_send_mail($to, $subject, $user_msg, $header)){ } else { echo "送信エラー\n"; } } } //管理者へメール送信 $to = $contact['parent']->reception_mail; $subject = $contact['parent']->admin_subject; //$from = mb_encode_mimeheader(" (自動送信メール) ").'<'.$contact['parent']->from_mail'>'; $from = $contact['parent']->from_mail; // $msg3 = ''; $msg3 .= $contact['parent']->admin_content; $msg3 .= "\n\n"; // if(!empty($form_recruit_name)){ $msg4 .= "■参照元の求人\n"; $msg4 .= " ".$form_recruit_name."\n"; $msg3 = $msg3.$msg4; } // $msg = $msg3.$base_msg; $msg = str_replace("\r", "", $msg); //mb_language("Japanese"); //mb_internal_encoding ("SJIS"); //$subject = mb_convert_encoding($subject, "SJIS", "auto"); //$msg_sjis = mb_convert_encoding($msg, "SJIS", "auto"); mb_language("ja"); mb_internal_encoding("UTF-8"); // if($file_flag == 1){ // ヘッダー設定 $header = ''; $header .= "Content-Type: multipart/mixed;boundary=\"__BOUNDARY__\"\n"; $header .= "Return-Path: " . $from . " \n"; $header .= "From: " . $from ." \n"; $header .= "Sender: " . $from ." \n"; $header .= "Organization: " . $from . " \n"; $header .= "X-Sender: " . $from . " \n"; $header .= "X-Priority: 3 \n"; // //$header .= "Reply-To: " . $from . " \n"; if(!empty($user_mail) && $contact['parent']->reply_flag == 1){ $header .= "Reply-To: " . "".mb_encode_mimeheader (mb_convert_encoding($user_mail,"ISO-2022-JP","AUTO")) ."" . "<".$user_mail."> \n"; }else{ $header .= "Reply-To: " . $from . " \n"; } // テキストメッセージを記述 $body = "--__BOUNDARY__\n"; $body .= "Content-Type: text/plain; charset=\"ISO-2022-JP\"\n\n"; $body .= $msg . "\n"; $body .= "--__BOUNDARY__\n"; // ファイルを添付 foreach($file_arrays as $file_array){ //$body .= "Content-Type: application/octet-stream; name=\"{$file_array['name']}\"\n"; //$body .= "Content-Disposition: attachment; filename=\"{$file_array['name']}\"\n"; $body .= "Content-Type: application/octet-stream; name=\"{$file_array['tmp_file_name']}\"\n"; $body .= "Content-Disposition: attachment; filename=\"{$file_array['tmp_file_name']}\"\n"; $body .= "Content-Transfer-Encoding: base64\n"; $body .= "\n"; if($file_array['type'] == 'application/pdf'){ //ディレクトリが存在するかチェック /*if(!file_exists('/var/www/html/application/webroot/common/upload_data/'.$file_array['subdomain'].'/file')){ exec('sudo mkdir /var/www/html/application/webroot/common/upload_data/'.$file_array['subdomain'].'/file'); exec('sudo chmod 777 /var/www/html/application/webroot/common/upload_data/'.$file_array['subdomain'].'/file'); }*/ $body .= chunk_split(base64_encode(file_get_contents("/var/www/html/application/webroot/common/upload_data/".$file_array['subdomain']."/file/".$file_array['tmp_file_name']))); }else{ $body .= chunk_split(base64_encode(file_get_contents("/var/www/html/application/webroot/common/upload_data/".$file_array['subdomain']."/image/".$file_array['tmp_file_name']))); } $body .= "--__BOUNDARY__\n"; } if(mb_send_mail($to, $subject, $body, $header)){ } else { echo "送信エラー\n"; } }else{ // ヘッダー設定 $header = ''; //$header .= "Content-Type: multipart/mixed;boundary=\"__BOUNDARY__\"\n"; $header .= "Return-Path: " . $from . " \n"; $header .= "From: " . $from ." \n"; $header .= "Sender: " . $from ." \n"; $header .= "Organization: " . $from . " \n"; $header .= "X-Sender: " . $from . " \n"; $header .= "X-Priority: 3 \n"; // //$header .= "Reply-To: " . $from . " \n"; if(!empty($user_mail) && $contact['parent']->reply_flag == 1){ $header .= "Reply-To: " . "".mb_encode_mimeheader (mb_convert_encoding($user_mail,"ISO-2022-JP","AUTO")) ."" . "<".$user_mail."> \n"; }else{ $header .= "Reply-To: " . $from . " \n"; } $subject_sjis = mb_convert_encoding($subject, "SJIS", "auto"); $msg_sjis = mb_convert_encoding($msg, "SJIS", "auto"); if(mb_send_mail($to, $subject, $msg, $header)){ } else { echo "送信エラー\n"; } } // //$this->Cookie->delete('ipp_lambda_form'); //$session->delete('ipp_lambda_form'); //完了画面へリダイレクト //return $this->redirect($this->request->data['back_url'].'form_send/'); //return $this->redirect($this->request->data['back_url'].'form_send/#'.$form_block_id); //return $this->redirect($this->request->data['back_url'].'form_send/'.$form_block_id.'/#'.$form_block_id); } //ContactLogs $contact_log = $this->ContactLogs->newEntity(); $contact_log_save_data['company_id'] = $company->id; $contact_log_save_data['contact_id'] = $contact_id; $contact_log_save_data['form_recruit_id'] = $form_recruit_id; $contact_log_save_data['content'] = $msg; $contact_log_save_data['user_agent'] = $_SERVER['HTTP_USER_AGENT']; $contact_log_save_data['remote_addr'] = $_SERVER['REMOTE_ADDR']; $contact_log_save_data['delete_flag'] = 0; $contact_log = $this->ContactLogs->patchEntity($contact_log, $contact_log_save_data); $this->ContactLogs->save($contact_log); }else{ //ContactLogs /*$contact_log = $this->ContactLogs->newEntity(); $contact_log_save_data['company_id'] = $company->id; $contact_log_save_data['contact_id'] = $contact_id; $contact_log_save_data['form_recruit_id'] = $form_recruit_id; $contact_log_save_data['content'] = $msg; $contact_log_save_data['user_agent'] = '[SPAM] '.$_SERVER['HTTP_USER_AGENT']; $contact_log_save_data['remote_addr'] = $_SERVER['REMOTE_ADDR']; $contact_log_save_data['delete_flag'] = 0; $contact_log = $this->ContactLogs->patchEntity($contact_log, $contact_log_save_data); $this->ContactLogs->save($contact_log);*/ } // //return $this->redirect($this->request->data['back_url'].'form_send/'.$form_block_id.'/#'.$form_block_id); return $this->redirect($form_url.'form_send/'.$form_block_id.'/#form_'.$form_block_id); /* }elseif($fixed_slug == 'form_send'){ if(!empty($contact_data['conversion_tag2'])){ $conversion_tag2 = $contact_data['conversion_tag2']; }else{ $conversion_tag2 = ''; } $this->set('conversion_tag2', $conversion_tag2); if($_SERVER['REMOTE_ADDR'] == '110.74.59.1'){ var_dump($conversion_tag2); } */ //フォームTOPからのPOST }else{ $file_count = 1; foreach($contact_details as $contact_detail){ //必須チェック if($contact_detail->required == 1 && empty($this->request->data[$contact_detail->id])){ if($contact_detail->type == 'text' || $contact_detail->type == 'textarea' || $contact_detail->type == 'mail' || $contact_detail->type == 'zip' || $contact_detail->type == 'address' || $contact_detail->type == 'birthday'){ $data['form_error_message'][$contact_detail->id] = $contact_detail->name.'が未入力です'; }else{ $data['form_error_message'][$contact_detail->id] = $contact_detail->name.'が未選択です'; } } // if($contact_detail->required == 1 && isset($this->request->data[$contact_detail->id]['year'])){ if(empty($this->request->data[$contact_detail->id]['year']) || empty($this->request->data[$contact_detail->id]['month']) || empty($this->request->data[$contact_detail->id]['day'])){ $data['form_error_message'][$contact_detail->id] = $contact_detail->name.'が未入力です'; } } //メールアドレスの形式チェック if($contact_detail->type == 'mail' && !empty($this->request->data[$contact_detail->id])){ if(!preg_match("/^([a-zA-Z0-9])+([a-zA-Z0-9\?\*\[|\]%'=~^\{\}\/\+!#&\$\._-])*@([a-zA-Z0-9_-])+\.([a-zA-Z0-9\._-]+)+$/", $this->request->data[$contact_detail->id])){ $data['form_error_message'][$contact_detail->id] = 'メールアドレスの形式が正しくありません'; } } //確認用メールアドレス if($contact_detail->type == 'mail' && $contact_detail->required == 1 && $contact_detail->content == 1){ if(empty($this->request->data['re_'.$contact_detail->id])){ $data['form_error_message']['re_'.$contact_detail->id] = $contact_detail->name.'(確認用)が未入力です'; }else{ if(!preg_match("/^([a-zA-Z0-9])+([a-zA-Z0-9\?\*\[|\]%'=~^\{\}\/\+!#&\$\._-])*@([a-zA-Z0-9_-])+\.([a-zA-Z0-9\._-]+)+$/", $this->request->data['re_'.$contact_detail->id])){ $data['form_error_message']['re_'.$contact_detail->id] = 'メールアドレスの形式が正しくありません'; } if($this->request->data['re_'.$contact_detail->id] != $this->request->data[$contact_detail->id]){ $data['form_error_message']['re_'.$contact_detail->id] = $contact_detail->name.'と内容が一致しません'; } } } // if($contact_detail->type == 'image'){ //ファイル必須チェック if($contact_detail->required == 1 && empty($this->request->data[$contact_detail->id]['tmp_name'])){ $data['form_error_message'][$contact_detail->id] = $contact_detail->name.'が未選択です'; }elseif(!empty($this->request->data[$contact_detail->id]['tmp_name'])){ if($this->request->data[$contact_detail->id]['type'] == 'application/pdf'){ //ディレクトリが存在するかチェック if(!file_exists('/var/www/html/application/webroot/common/upload_data/'.$company->subdomain.'/file')){ exec('sudo mkdir /var/www/html/application/webroot/common/upload_data/'.$company->subdomain.'/file'); exec('sudo chmod 777 /var/www/html/application/webroot/common/upload_data/'.$company->subdomain.'/file'); } //PDFの一時保存 $tmp_file_name = sha1($company->subdomain.date('YmdHis').$file_count).'.pdf'; $dirname_filename = '/var/www/html/application/webroot/common/upload_data/'.$company->subdomain.'/file/'.$tmp_file_name; move_uploaded_file($this->request->data[$contact_detail->id]['tmp_name'], $dirname_filename); // $this->request->data[$contact_detail->id]['tmp_file_name'] = $tmp_file_name; }else{ //画像の一時保存 $tmp_file_name = sha1($company->subdomain.date('YmdHis').$file_count); $imginfo = getimagesize($this->request->data[$contact_detail->id]['tmp_name']); if($imginfo[2] == 1){ $tmp_file_name = $tmp_file_name.'.gif'; }elseif($imginfo[2] == 2){ $tmp_file_name = $tmp_file_name.'.jpg'; }elseif($imginfo[2] == 3){ $tmp_file_name = $tmp_file_name.'.png'; }else{ $tmp_file_name = $row['name']; } $this->Img->upload('/var/www/html/application/webroot/common/upload_data/'.$company->subdomain.'/image', $this->request->data[$contact_detail->id]['tmp_name'], $tmp_file_name, 'original', 1024,$company->subdomain); //$this->request->data[$contact_detail->id]['binary'] = file_get_contents($this->request->data[$contact_detail->id]['tmp_name']); $this->request->data[$contact_detail->id]['tmp_file_name'] = $tmp_file_name; } } } $file_count++; } //エラーがある場合 if(!empty($data['form_error_message'])){ $data['form_input_data'] = $this->request->data; $ipp_lambda_form['form_data'] = $this->request->data; //※※※Cookie名に企業IDとか含めておいた方が良いかも //$this->Cookie->write('ipp_lambda_form', $ipp_lambda_form); $session->write('ipp_lambda_form', $ipp_lambda_form); //エラーが無い場合、Cookieにセットして確認画面へ }else{ if(isset($data['tmp_layer'])){ $ipp_lambda_form['back_url'] = $data['tmp_layer']; }else{ $ipp_lambda_form['back_url'] = ''; } $ipp_lambda_form['form_data'] = $this->request->data; //※※※Cookie名に企業IDとか含めておいた方が良いかも //$this->Cookie->write('ipp_lambda_form', $ipp_lambda_form); $session->write('ipp_lambda_form', $ipp_lambda_form); // //return $this->redirect($data['tmp_layer'].'form_conf/#'.$form_block_id); //return $this->redirect($data['tmp_layer'].'form_conf/'.$form_block_id.'/'); return $this->redirect($form_url.'form_conf/'.$form_block_id.'/'); } } } //問い合わせの確認画面の場合 if($fixed_slug == 'form_conf'){ //$tmp_form_data = $this->Cookie->read('ipp_lambda_form'); $tmp_form_data = $session->read('ipp_lambda_form'); $data['form_input_data'] = $tmp_form_data['form_data']; $data['back_url'] = $tmp_form_data['back_url']; } //問い合わせの送信完了画面の場合 if($fixed_slug == 'form_send'){ $tmp_form_data = $session->read('ipp_lambda_form'); $contact_id = $tmp_form_data['form_data']['contact_id']; $contact['parent'] = $this->Contacts->find() ->where(['Contacts.id' => $contact_id]) ->where(['Contacts.company_id' => $company->id]) ->where(['Contacts.delete_flag' => 0]) ->first(); // if(!empty($contact['parent']->conversion_tag2)){ $conversion_tag2 = $contact['parent']->conversion_tag2; }else{ $conversion_tag2 = ''; } $this->set('conversion_tag2', $conversion_tag2); if(!empty($contact['parent']->conversion_tag3)){ $conversion_tag3 = $contact['parent']->conversion_tag3; }else{ $conversion_tag3 = ''; } $this->set('conversion_tag3', $conversion_tag3); $session->delete('ipp_lambda_form'); } //全ページでTOPページの内容を使うのでここで取得 $data['top_page'] = $this->Newpages->find() ->select(['Newpages.id', 'Newpages.pagetype_id', 'Newpages.title']) ->where(['Newpages.company_id' => $company->id]) ->where(['Newpages.pagetype_id' => 1]) ->first(); //記事ページのタイトル if(!empty($data['setting']->seo_title)){ $data['top_page']->title = $data['top_page']->title.$data['setting']->seo_title_separate.$data['setting']->seo_title; } // if($slug_plus == '/sitemap/' || $slug == 'dictionary' || $slug_plus == '/cookie_policy/'){ }elseif($fixed_slug == 'comparison_archive' || ($fixed_slug == 'category' && $slug == 'comparison_archive')){ }elseif($page_mode == 'dictionary'){ //辞書データの取得 $data['dictionary'] = $this->Dictionaries->find() ->where(['Dictionaries.name' => urldecode($slug)]) ->where(['Dictionaries.company_id' => $company->id]) ->where(['Dictionaries.display_flag' => 1]) ->where(['Dictionaries.delete_flag' => 0]) ->first(); //用語が存在するかどうか if(!empty($data['dictionary'])){ $content_org = $data['dictionary']->content; //置換用の辞書データ取得 $tmp_dictionaries = $this->Dictionaries->find() ->where(['Dictionaries.id !=' => $data['dictionary']->id]) ->where(['Dictionaries.company_id' => $company->id]) ->where(['Dictionaries.display_flag' => 1]) ->where(['Dictionaries.delete_flag' => 0]) ->all(); $dictionary_datas = []; if($tmp_dictionaries){ foreach($tmp_dictionaries as $dictionary){ $dictionary_datas[$dictionary->name] = ''.$dictionary->name.''; } uksort($dictionary_datas, function($a, $b){return mb_strlen($b, 'utf-8') - mb_strlen($a, 'utf-8');}); $data['dictionary']->content = $this->strtr_utf8($data['dictionary']->content, $dictionary_datas); } $data['newpage'] = new \stdClass; $data['newpage']->id = ''; $data['newpage']->parent_id = '0'; $data['newpage']->pagetype_id = ''; $data['newpage']->name = ''.urldecode($slug).' とは'; $data['newpage']->keywords = urldecode($slug); $data['newpage']->description = mb_strimwidth($content_org, 0, 120, "…", "UTF-8" ); $data['newpage']->title = ''.urldecode($slug).' とは'; $data['newpage']->h1_text = urldecode($slug); $data['newpage']->slug = urldecode($slug); $data['newpage']->basic_account = ''; $data['newpage']->basic_password = ''; /*$data['newpage']->h_d_flag = 1; $data['newpage']->h_d_logo_flag = 1; $data['newpage']->h_d_navi_flag = 1; $data['newpage']->h_d_mv_flag = 1; $data['newpage']->f_d_flag = 1; $data['newpage']->f_d_logo_flag = 1; $data['newpage']->f_d_navi_flag = 1; $data['newpage']->f_d_sns_flag = 1;*/ $data['headers']['h_d_flag'] = 1; $data['headers']['h_d_logo_flag'] = 1; $data['headers']['h_d_navi_flag'] = 1; $data['headers']['h_d_mv_flag'] = 1; $data['footers']['f_d_flag'] = 1; $data['footers']['f_d_logo_flag'] = 1; $data['footers']['f_d_navi_flag'] = 1; $data['footers']['f_d_sns_flag'] = 1; $data['breadcrumb'][1]['url'] = '/'; $data['breadcrumb'][1]['name'] = $breadcrumb_text; $data['breadcrumb'][2]['url'] = '/dictionary/archive/'; $data['breadcrumb'][2]['name'] = '用語一覧'; $data['breadcrumb'][3]['url'] = '/dictionary/detail/'.urldecode($slug).'/'; $data['breadcrumb'][3]['name'] = urldecode($slug); //用語にスペースを含む場合の対策 $tmp_dic_slug = str_replace(array(" ", " ", " ", "+"), "", $slug); //用語を含むページの取得 $data['hierarchies'] = $this->Newpages->find() ->select(['Newpages.id', 'Newpages.pagetype_id', 'Newpages.parent_id', 'Newpages.name', 'Newpages.slug', 'Newpages.slug_plus', 'Newpages.description', 'Newpages.images']) ->where(['Newpages.company_id' => $company->id]) ->where(['Newpages.pagetype_id !=' => 7]) //->where(['Pages.content LIKE' => '%'.urldecode($slug).'%']) ->where(['Newpages.content LIKE' => '%'.urldecode($tmp_dic_slug).'%']) ->where(['Newpages.display_flag' => 1]) ->where(['Newpages.delete_flag' => 0]) ->limit(10); }else{ $data['newpage'] = ''; } if($data['setting']->webp_flag == 2){ $this->viewBuilder()->layout('newframe_webp/dictionary'); }else{ $this->viewBuilder()->layout('newframe/dictionary'); } }elseif($slug_plus == '/page/'){ $page_tag = urldecode($tag_category); $query = $this->Newpages->find() ->select(['Newpages.id', 'Newpages.slug', 'Newpages.name', 'Newpages.title', 'Newpages.images', 'Newpages.excerpt', 'Newpages.ameblo_content', 'Newpages.company_id', 'Newpages.pagetype_id', 'Newpages.release_date', 'Newpages.description', 'Newpages.display_flag', 'Newpages.delete_flag', 'NewpagesTags.id', 'NewpagesTags.newpage_id', 'NewpagesTags.tag_id', 'Tags.id', 'Tags.company_id', 'Tags.name', 'Tags.slug', 'Tags.content', 'Tags.sort', 'Tags.display_flag']) ->where(['Newpages.company_id' => $company->id]) //->where(['Pages.parent_id' => $data['page']->id]) //->where(['Newpages.pagetype_id IN' => [1, 2, 3, 4, 5, 6]]) //->where(['Newpages.pagetype_id IN' => [1, 2, 3, 4, 6]]) //->where(['Newpages.pagetype_id IN' => [4, 5, 6]]) ->where(['Newpages.pagetype_id !=' => 7]) ->where(['Newpages.display_flag' => 1]) ->where(['Newpages.delete_flag' => 0]) // ->where(['OR' => [['Newpages.release_date IS NULL'], ['Newpages.release_date <=' => date('Y-m-d H:i:s')]]]) //スロークエリ改善 //->order(['release_date' => 'DESC']); ->order(['Newpages.id' => 'DESC']); // $article_tag = urldecode($tag_category); // $tmp_tag = $this->Tags->find() ->where(['Tags.company_id' => $company->id]) ->where(['Tags.name' => urldecode($tag_category)]) ->where(['Tags.display_flag' => 1]) ->where(['Tags.delete_flag' => 0]) ->first(); $data['tmp_tag'] = $tmp_tag; if(empty($tmp_tag)){ return $this->redirect('404.html', '301'); }else{ $data['tmp_tag'] = $tmp_tag; } // /*$query->matching('Tags', function($q)use($tag_category) { //return $q->where(['BlogCategories.slug' => $tag_category]); return $q->where(['Tags.name' => urldecode($tag_category)]); });*/ $tmp_tag_id = $tmp_tag->id; $query->matching('Tags', function($q)use($tmp_tag_id){ //return $q->where(['BlogCategories.slug' => $tag_category]); return $q->where(['Tags.id' => $tmp_tag_id]); }); // //$articles = $query->all(); //$data['articles'] = $articles; // /*if(!empty($data['setting']->tag_num)){ $limit = $data['setting']->tag_num; }else{ $limit = 10; }*/ $limit = 10; $query->limit($limit); //件数やページ数のセット if(!empty($page_num)){ $offset = ($limit * $page_num) - $limit; $query->offset($offset); } $count = $query->count(); $articles = $query->all(); $data['articles'] = $articles; //ページネーション if(($count / $limit) > 0 && $count > 0){ $data['pagenation'] = $this->pagenation_data($page_num, $count, $limit); } // $data['tags'] = $this->Tags->find() ->where(['Tags.company_id' => $company->id]) //->where(['Tags.blog_id' => $tmp_page_id]) ->where(['Tags.display_flag' => 1]) ->where(['Tags.delete_flag' => 0]) ->order(['sort' => 'ASC']) ->all(); // $data['tmp_layer'] = '/page/tag/'.urldecode($tag_category).'/'; }else{ //ページデータの取得 if(isset($preview_id) && !empty($preview_id)){ $query = $this->Newpages->find() //->contain(['Pagetypes', 'Tags', 'BlogCategories']) ->contain(['Tags', 'BlogCategories', 'BlogTags', 'NewsCategories', 'Richresults']) ->where(['Newpages.id' => $preview_id]) ->where(['Newpages.company_id' => $company->id]) //->where(['Newpages.pagetype_id IN' => [1, 2, 3, 4, 5, 6, 8, 9, 10, 12, 13]]) //->where(['Newpages.display_flag' => 1]) ->where(['OR' => [['Newpages.delete_flag' => 0], ['Newpages.delete_flag' => 1]]]); $data['newpage'] = $query->first(); }else{ $query = $this->Newpages->find() //->contain(['Pagetypes', 'Tags', 'BlogCategories']) ->contain(['Tags', 'BlogCategories', 'BlogTags', 'NewsCategories', 'Richresults']) ->where(['Newpages.company_id' => $company->id]) ->where(['Newpages.pagetype_id IN' => [1, 2, 3, 4, 5, 6, 8, 9, 10, 12, 13, 14, 15]]) //->where(['Newpages.slug' => $request_uri]) //->where(['Newpages.slug_plus' => $request_uri]) //->where(['Newpages.slug_plus' => $slug_plus]) ->where(['Newpages.display_flag' => 1]) ->where(['Newpages.delete_flag' => 0]); if($slug_mode == 'slug'){ //$query->where(['Newpages.slug' => $slug]); $query->where(['Newpages.slug' => urldecode($slug)]); }else{ //$query->where(['Newpages.slug_plus' => $slug_plus]); $query->where(['Newpages.slug_plus' => urldecode($slug_plus)]); } $data['newpage'] = $query->first(); } //未来投稿対策 if(isset($data['newpage']->pagetype_id) && $data['newpage']->pagetype_id == 6 && $data['newpage']->release_date->format('Y-m-d H:i:s') > date('Y-m-d H:i:s') && $preview_mode != 'on'){ $data['newpage'] = ''; } //h1対策 if(isset($data['newpage']->h1_text) && empty($data['newpage']->h1_text)){ $data['newpage']->h1_text = $data['newpage']->title; } //記事ページ(pagetype_id:6)でdetailを含まない場合 $blog_news_detail_url = ''; if($data['newpage']->pagetype_id == 6 && strpos($request_uri, 'detail') === false){ // if(isset($preview_mode) && $preview_mode == 'on'){ $tmp_blog_detail_redirect = '/detail/'.$data['newpage']->slug.'/?mode=preview'; }else{ $tmp_blog_detail_redirect = '/detail/'.$data['newpage']->slug.'/'; } //親ページの取得 $tmp_blog_detail_data = $this->Newpages->find() ->where(['Newpages.id' => $data['newpage']->parent_id]) ->first(); $tmp_blog_detail_redirect = '/'.$tmp_blog_detail_data->slug.$tmp_blog_detail_redirect; if($tmp_blog_detail_data->parent_id != '' && $tmp_blog_detail_data->parent_id != 0){ $tmp_blog_detail_data2 = $this->Newpages->find() ->where(['Newpages.id' => $tmp_blog_detail_data->parent_id]) ->first(); $tmp_blog_detail_redirect = '/'.$tmp_blog_detail_data2->slug.$tmp_blog_detail_redirect; } // return $this->redirect($tmp_blog_detail_redirect, '301'); }else{ $blog_news_detail_url = $request_uri; } if(!empty($data['newpage'])){ $data['entries'] = json_decode($data['newpage']->entries, true); $data['entries']['entry_text'] = str_replace('', '
', $data['entries']['entry_text']); $data['entries']['entry_text2'] = str_replace('', '
', $data['entries']['entry_text2']); $data['headers'] = json_decode($data['newpage']->headers, true); $data['footers'] = json_decode($data['newpage']->footers, true); $data['others'] = json_decode($data['newpage']->others, true); $data['images'] = json_decode($data['newpage']->images, true); }else{ $this->setAction('routing'); return; /*$data['entries'] = ''; $data['headers'] = ''; $data['footers'] = ''; $data['others'] = ''; $data['images'] = '';*/ } } /*sub_navigation_old*/ //ベースのパンくずリスト $is_hybrid = $this->LandingPages->exists([ 'newpages_id' => $data['newpage']->id, 'is_deleted' => 0 ]) || $this->PillarPages->exists([ 'newpages_id' => $data['newpage']->id, 'is_deleted' => 0 ]); if($is_hybrid){ $data['breadcrumb'] = []; }elseif(!empty($data['newpage']->parent_id)){ $bc_page = $this->Newpages->find() ->select(['Newpages.id', 'Newpages.parent_id', 'Newpages.slug_plus', 'Newpages.name']) ->where(['Newpages.id' => $data['newpage']->parent_id]) ->where(['Newpages.company_id' => $company->id]) ->where(['Newpages.display_flag' => 1]) ->where(['Newpages.delete_flag' => 0]) ->first(); if(!empty($bc_page->parent_id)){ $bc_page2 = $this->Newpages->find() ->select(['Newpages.id', 'Newpages.parent_id', 'Newpages.slug_plus', 'Newpages.name']) ->where(['Newpages.id' => $bc_page->parent_id]) ->where(['Newpages.company_id' => $company->id]) ->where(['Newpages.display_flag' => 1]) ->where(['Newpages.delete_flag' => 0]) ->first(); $data['breadcrumb'][1]['url'] = '/'; $data['breadcrumb'][1]['name'] = $breadcrumb_text; $data['breadcrumb'][2]['id'] = $bc_page2->id; $data['breadcrumb'][2]['url'] = $bc_page2->slug_plus; $data['breadcrumb'][2]['name'] = $bc_page2->name; $data['breadcrumb'][3]['id'] = $bc_page->id; $data['breadcrumb'][3]['url'] = $bc_page->slug_plus; $data['breadcrumb'][3]['name'] = $bc_page->name; $data['breadcrumb'][4]['id'] = $data['newpage']->id; //$data['breadcrumb'][4]['url'] = $data['newpage']->slug_plus; if($data['newpage']->pagetype_id == 6){ $data['breadcrumb'][4]['url'] = $blog_news_detail_url; }else{ $data['breadcrumb'][4]['url'] = $data['newpage']->slug_plus; } $data['breadcrumb'][4]['name'] = $data['newpage']->name; }else{ $data['breadcrumb'][1]['url'] = '/'; $data['breadcrumb'][1]['name'] = $breadcrumb_text; $data['breadcrumb'][2]['id'] = $bc_page->id; $data['breadcrumb'][2]['url'] = $bc_page->slug_plus; $data['breadcrumb'][2]['name'] = $bc_page->name; $data['breadcrumb'][3]['id'] = $data['newpage']->id; //$data['breadcrumb'][3]['url'] = $data['newpage']->slug_plus; if($data['newpage']->pagetype_id == 6){ $data['breadcrumb'][3]['url'] = $blog_news_detail_url; }else{ $data['breadcrumb'][3]['url'] = $data['newpage']->slug_plus; } $data['breadcrumb'][3]['name'] = $data['newpage']->name; } }elseif($page_mode == 'dictionary'){ }else{ if(isset($data['newpage'])){ $data['breadcrumb'][1]['url'] = '/'; $data['breadcrumb'][1]['name'] = $breadcrumb_text; $data['breadcrumb'][2]['id'] = $data['newpage']->id; $data['breadcrumb'][2]['url'] = $data['newpage']->slug_plus; $data['breadcrumb'][2]['name'] = $data['newpage']->name; } } //TOP・固定ページの場合 if(isset($data['newpage']) && ($data['newpage']->pagetype_id == 1 || $data['newpage']->pagetype_id == 4)){ $data['html'] = $data['newpage']->html; preg_match_all('/{newblock_id:(.*?)}/s', $data['html'], $newblock_ids); // if($fixed_slug == 'form_conf' || $fixed_slug == 'form_send'){ foreach($newblock_ids[1] as $key=>$newblock_id){ $html = ''; if($newblock_id == $form_block_id){ $html = $this->blockToHtml($company->id, $company->subdomain, $newblock_id, $slug_plus, $fixed_slug, $data['form_error_message'], $data['setting']->logo_image, $contact_gallery_id, $company->cms_version, $contact_recruit_id, $data['newpage']->id, $page_num); } $data['html'] = str_replace($newblock_ids[0][$key], $html, $data['html']); } }else{ foreach($newblock_ids[1] as $key=>$newblock_id){ $html = ''; $html = $this->blockToHtml($company->id, $company->subdomain, $newblock_id, $slug_plus, $fixed_slug, $data['form_error_message'], $data['setting']->logo_image, $contact_gallery_id, $company->cms_version, $contact_recruit_id, $data['newpage']->id, $page_num); $data['html'] = str_replace($newblock_ids[0][$key], $html, $data['html']); } } //辞書機能 if(isset($data['html']) && !empty($data['html']) && $data['setting']->dictionary_mode != 2){ $data['html'] = $this->new_dictionary_data($company->id, $slug, $data['html'], $data['setting']->dictionary_mode, $data['setting']->dictionary_tooltip); } // if($data['newpage']->pagetype_id == 1){ if($data['setting']->webp_flag == 2){ $this->viewBuilder()->layout('newframe_webp/index'); }else{ $this->viewBuilder()->layout('newframe/index'); } }elseif($data['newpage']->pagetype_id == 4){ if($data['setting']->webp_flag == 2){ $this->viewBuilder()->layout('newframe_webp/single'); }else{ $this->viewBuilder()->layout('newframe/single'); } } if($data['newpage']->pagetype_id == 4){ //※※※pageが記事(pagetypeが6)の場合、関連記事の取得をどうするか //上下階層の前ページを取得する様に仕様変更 //最上位のpage_idを$tmp_parent_idにセット $tmp_hierarchy_id = $data['newpage']->id; $tmp_parent_id = $data['newpage']->parent_id; while($tmp_parent_id != 0){ $tmp_child_page = $this->Newpages->find() ->where(['Newpages.company_id' => $company->id]) ->where(['Newpages.id' => $tmp_parent_id]) ->where(['Newpages.basic_account' => '']) ->where(['Newpages.basic_password' => '']) ->first(); $tmp_hierarchy_id = $tmp_child_page->id; $tmp_parent_id = $tmp_child_page->parent_id; } // $data['hierarchies'] = []; $relations_not_id_array = []; $relations_not_id_array[] = $data['newpage']->id; //TOPを第一階層とした場合、第二回層のデータ1件を取得 if($data['newpage']->id != $tmp_hierarchy_id){ $tmp_hierarchy = $this->Newpages->find() ->select(['Newpages.id', 'Newpages.pagetype_id', 'Newpages.parent_id', 'Newpages.name', 'Newpages.slug', 'Newpages.slug_plus', 'Newpages.title', 'Newpages.sort', 'Newpages.description', 'Newpages.images', 'Pagetypes.id', 'Pagetypes.name']) ->contain(['Pagetypes']) ->where(['Newpages.company_id' => $company->id]) ->where(['Newpages.id' => $tmp_hierarchy_id]) ->where(['OR' => [['Newpages.pagetype_id' => 2], ['Newpages.pagetype_id' => 3], ['Newpages.pagetype_id' => 4], ['Newpages.pagetype_id' => 5]]]) ->where(['Newpages.display_flag' => 1]) ->where(['Newpages.delete_flag' => 0]) ->where(['Newpages.basic_account' => '']) ->where(['Newpages.basic_password' => '']) ->first(); if(!empty($tmp_hierarchy)){ $data['hierarchies'][] = $tmp_hierarchy; $relations_not_id_array[] = $tmp_hierarchy->id; } } //TOPを第一階層とした場合、第二回層のデータ1件に紐付く第三階層のデータを複数取得 $tmp_hierarchies1 = $this->Newpages->find() ->select(['Newpages.id', 'Newpages.pagetype_id', 'Newpages.parent_id', 'Newpages.name', 'Newpages.slug', 'Newpages.slug_plus', 'Newpages.title', 'Newpages.sort', 'Newpages.description', 'Newpages.images', 'Pagetypes.id', 'Pagetypes.name']) ->contain(['Pagetypes']) ->where(['Newpages.id !=' => $data['newpage']->id]) ->where(['Newpages.company_id' => $company->id]) ->where(['Newpages.parent_id' => $tmp_hierarchy_id]) ->where(['OR' => [['Newpages.pagetype_id' => 2], ['Newpages.pagetype_id' => 3], ['Newpages.pagetype_id' => 4], ['Newpages.pagetype_id' => 5]]]) ->where(['Newpages.display_flag' => 1]) ->where(['Newpages.delete_flag' => 0]) ->where(['Newpages.basic_account' => '']) ->where(['Newpages.basic_password' => '']) ->all(); if(!$tmp_hierarchies1->isEmpty()){ foreach($tmp_hierarchies1 as $tmp_hierarchy1){ // $data['hierarchies'][] = $tmp_hierarchy1; $relations_not_id_array[] = $tmp_hierarchy1->id; //TOPを第一階層とした場合、第三回層のデータ1件に紐付く第四階層のデータを複数取得 $tmp_hierarchies2 = $this->Newpages->find() ->select(['Newpages.id', 'Newpages.pagetype_id', 'Newpages.parent_id', 'Newpages.name', 'Newpages.slug', 'Newpages.slug_plus', 'Newpages.title', 'Newpages.sort', 'Newpages.description', 'Newpages.images', 'Pagetypes.id', 'Pagetypes.name']) ->contain(['Pagetypes']) ->where(['Newpages.id !=' => $data['newpage']->id]) ->where(['Newpages.company_id' => $company->id]) ->where(['Newpages.parent_id' => $tmp_hierarchy1->id]) ->where(['OR' => [['Newpages.pagetype_id' => 2], ['Newpages.pagetype_id' => 3], ['Newpages.pagetype_id' => 4], ['Newpages.pagetype_id' => 5]]]) ->where(['Newpages.display_flag' => 1]) ->where(['Newpages.delete_flag' => 0]) ->where(['Newpages.basic_account' => '']) ->where(['Newpages.basic_password' => '']) ->all(); if(!$tmp_hierarchies2->isEmpty()){ foreach($tmp_hierarchies2 as $tmp_hierarchy2){ $data['hierarchies'][] = $tmp_hierarchy2; $relations_not_id_array[] = $tmp_hierarchy2->id; } } } } //関連度の高いページを取得※※※aaa $data['relations'] = []; $relation_data = []; //フレーム一覧を取得 $query = $this->Newpages->find('all') //->select(['Pages.id', 'Pages.name', 'Pages.slug', 'Pagetypes.name', 'Pagetypes.abbr', 'Tags.name']) ->select(['Newpages.id', 'Newpages.parent_id', 'Newpages.name', 'Newpages.slug', 'Newpages.html', 'Newpages.description', 'Newpages.images']) ->contain(['Tags']) ->where(['Newpages.company_id' => $company->id]) //TOPと固定ページのみ対象 //->where(['Newpages.pagetype_id IN' => [1, 4]]) ->where(['Newpages.pagetype_id' => 4]) ->where(['Newpages.display_flag' => 1]) ->where(['Newpages.delete_flag' => 0]) //『関連ページを表示する』にチェックが入っていないページは除外 ->where(['Newpages.related_posts_flag' => 1]) ->where(['Newpages.basic_account' => '']) ->where(['Newpages.basic_password' => '']) ->where([ 'NOT' => ['Newpages.id IN' => $relations_not_id_array] ]) ->order(['Newpages.sort' => 'ASC']); //->toArray(); $relation_data['pages'] = $query->toArray(); // //$return_data = []; if(!empty($relation_data['pages'])){ //TOP $count = 1; /*foreach($relation_data['pages'] as $row){ if(is_null($row->parent_id)){ $save_data['name'] = $row->name; $save_data['image01'] = $row->image01; $save_data['layer_num'] = 1; $save_data['slug_plus'] = '/'; //該当ページの文字数 $total_count = mb_strlen($row->content, 'UTF-8'); if($total_count != 0){ // $match_rate = 0; foreach($data['page']->tags as $tmp_tag){ //キーワードの出現回数 $occurrences = mb_substr_count($row->content, $tmp_tag->name); //キーワードのトータル文字数 $keyword_count = mb_strlen($tmp_tag->name, 'UTF-8') * $occurrences; //キーワード占有率 $match_rate = $match_rate + ($keyword_count / $total_count * 100); } $save_data['match_rate'] = round($match_rate, 2); }else{ $save_data['match_rate'] = 0; } $data['relations'][] = $save_data; $count++; } }*/ foreach($relation_data['pages'] as $row1){ //if($row1->parent_id == 0 && !is_null($row1->parent_id)){ if($row1->parent_id == 0 && $row1->pagetype_id != 1){ $save_data['id'] = $row1->id; $save_data['name'] = $row1->name; //$save_data['image01'] = $row1->image01; $save_data['layer_num'] = 2; $save_data['slug_plus'] = '/'.$row1->slug.'/'; $save_data['description'] = $row1->description; $save_data['images'] = $row1->images; //該当ページの文字数 $tmp1_content = strip_tags($row1->html); //$total_count = mb_strlen($row1->content, 'UTF-8'); $total_count = mb_strlen($tmp1_content, 'UTF-8'); if($total_count != 0){ // $match_rate = 0; /*if($_SERVER['REMOTE_ADDR'] == '110.74.59.1'){ var_dump($data['newpage']->tags); }*/ foreach($data['newpage']->tags as $tmp_tag){ //キーワードの出現回数 //$occurrences = mb_substr_count($row1->content, $tmp_tag->name); $occurrences = mb_substr_count($tmp1_content, $tmp_tag->name); //キーワードのトータル文字数 $keyword_count = mb_strlen($tmp_tag->name, 'UTF-8') * $occurrences; //キーワード占有率 $match_rate = $match_rate + ($keyword_count / $total_count * 100); } if(round($match_rate, 2) == 0){ $save_data['match_rate'] = 0; }else{ $save_data['match_rate'] = round($match_rate, 2).$count; $data['relations'][]= $save_data; $count++; } }else{ $save_data['match_rate'] = 0; } //$data['relations'][]= $save_data; //$count++; foreach($relation_data['pages'] as $row2){ if($row2->parent_id == $row1->id){ $save_data['id'] = $row2->id; $save_data['name'] = $row2->name; //$save_data['image01'] = $row2->image01; $save_data['layer_num'] = 3; $save_data['slug_plus'] = '/'.$row1->slug.'/'.$row2->slug.'/'; $save_data['description'] = $row2->description; $save_data['images'] = $row2->images; //該当ページの文字数 $tmp2_content = strip_tags($row2->html); //$total_count = mb_strlen($row2->content, 'UTF-8'); $total_count = mb_strlen($tmp2_content, 'UTF-8'); if($total_count != 0){ // $match_rate = 0; foreach($data['newpage']->tags as $tmp_tag){ //キーワードの出現回数 //$occurrences = mb_substr_count($row2->content, $tmp_tag->name); $occurrences = mb_substr_count($tmp2_content, $tmp_tag->name); //キーワードのトータル文字数 $keyword_count = mb_strlen($tmp_tag->name, 'UTF-8') * $occurrences; //キーワード占有率 $match_rate = $match_rate + ($keyword_count / $total_count * 100); } if(round($match_rate, 2) == 0){ $save_data['match_rate'] = 0; }else{ $save_data['match_rate'] = round($match_rate, 2).$count; $data['relations'][] = $save_data; $count++; } }else{ $save_data['match_rate'] = 0; } //$data['relations'][] = $save_data; //$count++; foreach($relation_data['pages'] as $row3){ if($row3->parent_id == $row2->id){ $save_data['id'] = $row3->id; $save_data['parent_id'] = $row2->id; $save_data['name'] = $row3->name; //$save_data['image01'] = $row3->image01; $save_data['layer_num'] = 4; $save_data['slug_plus'] = '/'.$row1->slug.'/'.$row2->slug.'/'.$row3->slug.'/'; $save_data['description'] = $row3->description; $save_data['images'] = $row3->images; //該当ページの文字数 $tmp3_content = strip_tags($row3->html); //$total_count = mb_strlen($row3->content, 'UTF-8'); $total_count = mb_strlen($tmp3_content, 'UTF-8'); if($total_count != 0){ // $match_rate = 0; foreach($data['newpage']->tags as $tmp_tag){ //キーワードの出現回数 //$occurrences = mb_substr_count($row3->content, $tmp_tag->name); $occurrences = mb_substr_count($tmp3_content, $tmp_tag->name); //キーワードのトータル文字数 $keyword_count = mb_strlen($tmp_tag->name, 'UTF-8') * $occurrences; //キーワード占有率 $match_rate = $match_rate + ($keyword_count / $total_count * 100); } if(round($match_rate, 2) == 0){ $save_data['match_rate'] = 0; }else{ $save_data['match_rate'] = round($match_rate, 2).$count; $data['relations'][] = $save_data; $count++; } }else{ $save_data['match_rate'] = 0; } //$data['relations'][] = $save_data; //$count++; } } } } } } } //sort用のID配列 $match_rate = []; foreach($data['relations'] as $key=>$val){ $match_rate[$key] = $val['match_rate']; } array_multisort($match_rate, SORT_DESC, $data['relations']); } //辞書一覧の場合 }elseif($slug == 'dictionary'){ $query = $this->Dictionaries->find() ->where(['Dictionaries.company_id' => $company->id]) ->where(['Dictionaries.display_flag' => 1]) ->where(['Dictionaries.delete_flag' => 0]); //->order(['release_date' => 'DESC']) // if(!empty($data['setting']->dictionary_num)){ $limit = $data['setting']->dictionary_num; }else{ $limit = 10; } $query->limit($limit); //件数やページ数のセット if(!empty($page_num)){ $offset = ($limit * $page_num) - $limit; $query->offset($offset); } $count = $query->count(); $dictionaries = $query->all(); $data['dictionaries'] = $dictionaries; //ページネーション if(($count / $limit) > 0 && $count > 0){ $data['pagenation'] = $this->pagenation_data($page_num, $count, $limit); } $data['newpage'] = new \stdClass; $data['newpage']->id = ''; $data['newpage']->parent_id = '0'; $data['newpage']->pagetype_id = ''; $data['newpage']->name = '用語一覧'; $data['newpage']->keywords = '用語一覧'; $data['newpage']->description = '用語一覧'; $data['newpage']->title = '用語一覧'; $data['newpage']->h1_text = '用語一覧'; $data['newpage']->name = '用語一覧'; $data['newpage']->slug = 'dictionary'; $data['newpage']->basic_account = ''; $data['newpage']->basic_password = ''; /*$data['newpage']->h_d_flag = 1; $data['newpage']->h_d_logo_flag = 1; $data['newpage']->h_d_navi_flag = 1; $data['newpage']->h_d_mv_flag = 1; $data['newpage']->f_d_flag = 1; $data['newpage']->f_d_logo_flag = 1; $data['newpage']->f_d_navi_flag = 1; $data['newpage']->f_d_sns_flag = 1;*/ $data['headers']['h_d_flag'] = 1; $data['headers']['h_d_logo_flag'] = 1; $data['headers']['h_d_navi_flag'] = 1; $data['headers']['h_d_mv_flag'] = 1; $data['footers']['f_d_flag'] = 1; $data['footers']['f_d_logo_flag'] = 1; $data['footers']['f_d_navi_flag'] = 1; $data['footers']['f_d_sns_flag'] = 1; $data['breadcrumb'][1]['url'] = '/'; $data['breadcrumb'][1]['name'] = $breadcrumb_text; $data['breadcrumb'][2]['url'] = '/dictionary/archive/'; $data['breadcrumb'][2]['name'] = '用語一覧'; // $data['tmp_layer'] = '/dictionary/archive/'; if($data['setting']->webp_flag == 2){ $this->viewBuilder()->layout('newframe_webp/d_archive'); }else{ $this->viewBuilder()->layout('newframe/d_archive'); } //ブログ・新着情報・コラム・マルチギャラリー一覧の場合 }elseif(isset($data['newpage']) && ($data['newpage']->pagetype_id == 2 || $data['newpage']->pagetype_id == 3 || $data['newpage']->pagetype_id == 5 || $data['newpage']->pagetype_id == 12)){ //表示件数 if(!empty($data['others']['other2'])){ $limit = $data['others']['other2']; }else{ $limit = 10; } //件数やページ数のセット if(!empty($page_num)){ $offset = ($limit * $page_num) - $limit; //$query->offset($offset); } //ブログカテゴリ一覧のキャッシュがある場合の処理 if($fixed_slug == 'category'){ // $data['parent_category'] = $this->BlogCategories->find() ->where(['BlogCategories.company_id' => $company->id]) ->where(['BlogCategories.blog_id' => $data['newpage']->id]) ->where(['BlogCategories.name' => urldecode($tag_category)]) //->where(['BlogCategories.name' => $tag_category]) ->where(['BlogCategories.display_flag' => 1]) ->where(['BlogCategories.delete_flag' => 0]) ->first(); $blog_parent_id = $data['parent_category']->id; /*if(empty($data['parent_category'])){ return $this->redirect('404.html', '301'); }else{ $blog_parent_id = $data['parent_category']->id; }*/ } if($data['newpage']->pagetype_id == 2 && $data['others']['archive_cache'] == 1 && $fixed_slug == 'category' && ($blog_archive_cache = Cache::read($company->id.'_'.$data['parent_category']->id.'_'.$offset, 'blog_category_archive')) !== false){ // $data['articles'] = $blog_archive_cache['articles']; $article_count = $blog_archive_cache['article_count']; $limit = $blog_archive_cache['limit']; $total_result = $blog_archive_cache['total_result']; $result_start = $blog_archive_cache['result_start']; $result_end = $blog_archive_cache['result_end']; } //ブログカテゴリ一覧キャッシュ実装前の通常処理 //記事一覧の取得DISTINCT $query = $this->Newpages->find() ->distinct(['Newpages.id']) ->where(['Newpages.company_id' => $company->id]) ->where(['Newpages.parent_id' => $data['newpage']->id]) ->where(['Newpages.pagetype_id' => 6]) ->where(['Newpages.display_flag' => 1]) ->where(['Newpages.release_date <=' => date('Y-m-d H:i:s')]) ->where(['Newpages.delete_flag' => 0]) //->order(['Newpages.release_date' => 'DESC']); ->order(['Newpages.release_date' => 'DESC', 'Newpages.id' => 'DESC']); //年月アーカイブの場合 if(!empty($archive_year) && !empty($archive_month)){ $query->where(['Newpages.release_date LIKE' => $archive_year.'-'.$archive_month.'%']); } //ブログの場合 if($data['newpage']->pagetype_id == 2){ if($fixed_slug == 'detail'){ //$this->setAction('routing'); //return; return $this->redirect('404.html', '301'); } // if($data['others']['other1'] == 7){ $query->contain(['BlogCategories']); } // $data['categories'] = $this->BlogCategories->find() ->where(['BlogCategories.company_id' => $company->id]) ->where(['BlogCategories.blog_id' => $data['newpage']->id]) ->where(['BlogCategories.display_flag' => 1]) ->where(['BlogCategories.delete_flag' => 0]) ->order(['sort' => 'ASC']) ->all(); $data['tags'] = $this->Tags->find() ->where(['Tags.company_id' => $company->id]) //->where(['Tags.blog_id' => $tmp_page_id]) ->where(['Tags.display_flag' => 1]) ->where(['Tags.delete_flag' => 0]) ->order(['sort' => 'ASC']) ->all(); $data['resent_posts'] = $this->Newpages->find() ->where(['Newpages.company_id' => $company->id]) ->where(['Newpages.parent_id' => $data['newpage']->id]) ->where(['Newpages.pagetype_id' => 6]) ->where(['Newpages.display_flag' => 1]) ->where(['Newpages.delete_flag' => 0]) ->where(['Newpages.release_date <=' => date('Y-m-d H:i:s')]) //->order(['Newpages.release_date' => 'DESC']) ->order(['Newpages.release_date' => 'DESC', 'Newpages.id' => 'DESC']) ->limit(3) ->all(); //カテゴリやタグの絞り込み if($fixed_slug == 'category'){ /*$query->matching('BlogCategories', function($q)use($tag_category){ return $q->where(['BlogCategories.name' => urldecode($tag_category)]); });*/ // /*$data['parent_category'] = $this->BlogCategories->find() ->where(['BlogCategories.company_id' => $company->id]) ->where(['BlogCategories.blog_id' => $data['newpage']->id]) ->where(['BlogCategories.name' => urldecode($tag_category)]) ->first(); $blog_parent_id = $data['parent_category']->id;*/ //$query->matching('BlogCategories', function($q)use($blog_parent_id){ if(empty($data['parent_category'])){ return $this->redirect('404.html', '301'); } $query->innerJoinWith('BlogCategories', function($q)use($blog_parent_id){ return $q->where(['BlogCategories.id' => $blog_parent_id]); }); // if(!empty($data['parent_category']->h1_text)){ $data['newpage']->h1_text = $data['parent_category']->h1_text; } //※※※ $data['tmp_layer'] = $slug_plus.'category/'.urldecode($tag_category).'/'; }elseif($fixed_slug == 'tag'){ //Blog用のタグではなく、Page用のタグを用いる /*$query->matching('Tags', function($q)use($tag_category){ return $q->where(['Tags.name' => urldecode($tag_category)]); });*/ // $tmp_tag = $this->Tags->find() ->where(['Tags.company_id' => $company->id]) ->where(['Tags.name' => urldecode($tag_category)]) ->first(); if(empty($tmp_tag)){ return $this->redirect('404.html', '301'); } // /*$query->matching('Tags', function($q)use($tag_category) { //return $q->where(['BlogCategories.slug' => $tag_category]); return $q->where(['Tags.name' => urldecode($tag_category)]); });*/ $tmp_tag_id = $tmp_tag->id; $query->matching('Tags', function($q)use($tmp_tag_id) { //return $q->where(['BlogCategories.slug' => $tag_category]); return $q->where(['Tags.id' => $tmp_tag_id]); }); // $data['parent_tag'] = $this->Tags->find() ->where(['Tags.company_id' => $company->id]) ->where(['Tags.name' => urldecode($tag_category)]) ->first(); } //年月アーカイブリンク用のデータ取得 if($data['others']['other3'] == 1){ //一番古い記事を取得 $oldest_page = $this->Newpages->find() ->where(['Newpages.company_id' => $company->id]) ->where(['Newpages.parent_id' => $data['newpage']->id]) ->where(['Newpages.pagetype_id' => 6]) ->where(['Newpages.display_flag' => 1]) ->where(['Newpages.release_date <=' => date('Y-m-d H:i:s')]) ->where(['Newpages.delete_flag' => 0]) ->order(['Newpages.release_date' => 'ASC']) ->first(); $data['archives'] = []; if(!empty($oldest_page)){ $oldest_year = $oldest_page->release_date->format('Y'); for($year=date('Y');$year>=$oldest_year;$year--){ $data['archives'][$year] = []; $month_count = 0; for($month=12;$month>=1;$month--){ if($year == date('Y') && $month > date('n')){ }else{ $month_str = sprintf("%02d",$month); $count = 0; if(($count = Cache::read($company->id.'_blog_'.$data['newpage']->id.$year.'-'.$month_str, 'blog_archive')) === false){ $count = $this->Newpages->find() ->where(['Newpages.company_id' => $company->id]) ->where(['Newpages.parent_id' => $data['newpage']->id]) ->where(['Newpages.pagetype_id' => 6]) ->where(['Newpages.display_flag' => 1]) //->where(['Pages.release_date <=' => date('Y-m-d H:i:s')]) ->where(['AND' => [['Newpages.release_date <=' => date('Y-m-d H:i:s')], ['Newpages.release_date LIKE' => $year.'-'.$month_str.'%']]]) ->where(['Newpages.delete_flag' => 0]) ->order(['release_date' => 'DESC']) ->count(); //キャッシュの書き込み Cache::write($company->id.'_blog_'.$data['newpage']->id.$year.'-'.$month_str, $count, 'blog_archive'); } $data['archives'][$year][$month_str] = $count; $month_count = $month_count + $count; } } if($month_count == 0){ unset($data['archives'][$year]); } } } } //コラムの場合 }elseif($data['newpage']->pagetype_id == 5){ $query->contain(['ColumnCategories']); // $data['categories'] = $this->ColumnCategories->find() ->where(['ColumnCategories.company_id' => $company->id]) ->where(['ColumnCategories.column_id' => $data['newpage']->id]) ->where(['ColumnCategories.display_flag' => 1]) ->where(['ColumnCategories.delete_flag' => 0]) ->order(['sort' => 'ASC']) ->all(); $data['tags'] = $this->Tags->find() ->where(['Tags.company_id' => $company->id]) //->where(['Tags.column_id' => $tmp_page_id]) ->where(['Tags.display_flag' => 1]) ->where(['Tags.delete_flag' => 0]) ->order(['sort' => 'ASC']) ->all(); $data['resent_posts'] = $this->Newpages->find() ->where(['Newpages.company_id' => $company->id]) ->where(['Newpages.parent_id' => $data['newpage']->id]) ->where(['Newpages.pagetype_id' => 6]) ->where(['Newpages.display_flag' => 1]) ->where(['Newpages.delete_flag' => 0]) ->where(['Newpages.release_date <=' => date('Y-m-d H:i:s')]) //->order(['Newpages.release_date' => 'DESC']) ->order(['Newpages.release_date' => 'DESC', 'Newpages.id' => 'DESC']) ->limit(3) ->all(); //カテゴリやタグの絞り込み if($fixed_slug == 'category'){ /*$query->matching('ColumnCategories', function($q)use($tag_category){ return $q->where(['ColumnCategories.name' => urldecode($tag_category)]); });*/ // $data['parent_category'] = $this->ColumnCategories->find() ->where(['ColumnCategories.company_id' => $company->id]) ->where(['ColumnCategories.column_id' => $data['newpage']->id]) ->where(['ColumnCategories.name' => urldecode($tag_category)]) ->first(); if(empty($data['parent_category'])){ return $this->redirect('404.html', '301'); }else{ $column_parent_id = $data['parent_category']->id; } $query->matching('ColumnCategories', function($q)use($column_parent_id){ return $q->where(['ColumnCategories.id' => $column_parent_id]); }); if(!empty($data['parent_category']->h1_text)){ $data['newpage']->h1_text = $data['parent_category']->h1_text; } //※※※ $data['tmp_layer'] = $slug_plus.'category/'.urldecode($tag_category).'/'; }elseif($fixed_slug == 'tag'){ //column用のタグではなく、Page用のタグを用いる /*$query->matching('Tags', function($q)use($tag_category){ return $q->where(['Tags.name' => urldecode($tag_category)]); });*/ // $tmp_tag = $this->Tags->find() ->where(['Tags.company_id' => $company->id]) ->where(['Tags.name' => urldecode($tag_category)]) ->first(); if(empty($tmp_tag)){ return $this->redirect('404.html', '301'); } // /*$query->matching('Tags', function($q)use($tag_category) { //return $q->where(['ColumnCategories.slug' => $tag_category]); return $q->where(['Tags.name' => urldecode($tag_category)]); });*/ $tmp_tag_id = $tmp_tag->id; $query->matching('Tags', function($q)use($tmp_tag_id) { //return $q->where(['ColumnCategories.slug' => $tag_category]); return $q->where(['Tags.id' => $tmp_tag_id]); }); // $data['parent_tag'] = $this->Tags->find() ->where(['Tags.company_id' => $company->id]) ->where(['Tags.name' => urldecode($tag_category)]) ->first(); } //年月アーカイブリンク用のデータ取得 if($data['others']['other3'] == 1){ //一番古い記事を取得 $oldest_page = $this->Newpages->find() ->where(['Newpages.company_id' => $company->id]) ->where(['Newpages.parent_id' => $data['newpage']->id]) ->where(['Newpages.pagetype_id' => 6]) ->where(['Newpages.display_flag' => 1]) ->where(['Newpages.release_date <=' => date('Y-m-d H:i:s')]) ->where(['Newpages.delete_flag' => 0]) ->order(['Newpages.release_date' => 'ASC']) ->first(); $data['archives'] = []; if(!empty($oldest_page)){ $oldest_year = $oldest_page->release_date->format('Y'); for($year=date('Y');$year>=$oldest_year;$year--){ $data['archives'][$year] = []; $month_count = 0; for($month=12;$month>=1;$month--){ if($year == date('Y') && $month > date('n')){ }else{ $month_str = sprintf("%02d",$month); $count = 0; if(($count = Cache::read($company->id.'_column_'.$data['newpage']->id.$year.'-'.$month_str, 'column_archive')) === false){ $count = $this->Newpages->find() ->where(['Newpages.company_id' => $company->id]) ->where(['Newpages.parent_id' => $data['newpage']->id]) ->where(['Newpages.pagetype_id' => 6]) ->where(['Newpages.display_flag' => 1]) //->where(['Pages.release_date <=' => date('Y-m-d H:i:s')]) ->where(['AND' => [['Newpages.release_date <=' => date('Y-m-d H:i:s')], ['Newpages.release_date LIKE' => $year.'-'.$month_str.'%']]]) ->where(['Newpages.delete_flag' => 0]) ->order(['release_date' => 'DESC']) ->count(); //キャッシュの書き込み Cache::write($company->id.'_column_'.$data['newpage']->id.$year.'-'.$month_str, $count, 'column_archive'); } $data['archives'][$year][$month_str] = $count; $month_count = $month_count + $count; } } if($month_count == 0){ unset($data['archives'][$year]); } } } } //新着情報の場合 }elseif($data['newpage']->pagetype_id == 3){ $query->contain(['NewsCategories']); // $data['categories'] = $this->NewsCategories->find() ->where(['NewsCategories.company_id' => $company->id]) ->where(['NewsCategories.news_id' => $data['newpage']->id]) ->where(['NewsCategories.display_flag' => 1]) ->where(['NewsCategories.delete_flag' => 0]) ->order(['sort' => 'ASC']) ->all(); $data['resent_posts'] = $this->Newpages->find() ->where(['Newpages.company_id' => $company->id]) ->where(['Newpages.parent_id' => $data['newpage']->id]) ->where(['Newpages.pagetype_id' => 6]) ->where(['Newpages.display_flag' => 1]) ->where(['Newpages.delete_flag' => 0]) ->where(['Newpages.release_date <=' => date('Y-m-d H:i:s')]) //->order(['Newpages.release_date' => 'DESC']) ->order(['Newpages.release_date' => 'DESC', 'Newpages.id' => 'DESC']) ->limit(3) ->all(); //カテゴリやタグの絞り込み if($fixed_slug == 'category'){ /*$query->matching('NewsCategories', function($q)use($tag_category) { //return $q->where(['NewsCategories.slug' => $tag_category]); return $q->where(['NewsCategories.name' => urldecode($tag_category)]); });*/ // $data['parent_category'] = $this->NewsCategories->find() ->where(['NewsCategories.company_id' => $company->id]) ->where(['NewsCategories.news_id' => $data['newpage']->id]) ->where(['NewsCategories.name' => urldecode($tag_category)]) ->first(); if(empty($data['parent_category'])){ return $this->redirect('404.html', '301'); }else{ $news_parent_id = $data['parent_category']->id; } $query->matching('NewsCategories', function($q)use($news_parent_id){ return $q->where(['NewsCategories.id' => $news_parent_id]); }); //※※※ $data['tmp_layer'] = $slug_plus.'category/'.urldecode($tag_category).'/'; if(!empty($data['parent_category']->h1_text)){ $data['newpage']->h1_text = $data['parent_category']->h1_text; } } //年月アーカイブリンク用のデータ取得 if($data['others']['other3'] == 1){ //一番古い記事を取得 $oldest_page = $this->Newpages->find() ->where(['Newpages.company_id' => $company->id]) ->where(['Newpages.parent_id' => $data['newpage']->id]) ->where(['Newpages.pagetype_id' => 6]) ->where(['Newpages.display_flag' => 1]) ->where(['Newpages.release_date <=' => date('Y-m-d H:i:s')]) ->where(['Newpages.delete_flag' => 0]) ->order(['Newpages.release_date' => 'ASC']) ->first(); $data['archives'] = []; if(!empty($oldest_page)){ $oldest_year = $oldest_page->release_date->format('Y'); for($year=date('Y');$year>=$oldest_year;$year--){ $data['archives'][$year] = []; $month_count = 0; for($month=12;$month>=1;$month--){ if($year == date('Y') && $month > date('n')){ }else{ $month_str = sprintf("%02d",$month); $count = 0; if(($count = Cache::read($company->id.'_news_'.$data['newpage']->id.$year.'-'.$month_str, 'news_archive')) === false){ $count = $this->Newpages->find() ->where(['Newpages.company_id' => $company->id]) ->where(['Newpages.parent_id' => $data['newpage']->id]) ->where(['Newpages.pagetype_id' => 6]) ->where(['Newpages.display_flag' => 1]) //->where(['Pages.release_date <=' => date('Y-m-d H:i:s')]) ->where(['AND' => [['Newpages.release_date <=' => date('Y-m-d H:i:s')], ['Newpages.release_date LIKE' => $year.'-'.$month_str.'%']]]) ->where(['Newpages.delete_flag' => 0]) ->order(['release_date' => 'DESC']) ->count(); //キャッシュの書き込み Cache::write($company->id.'_news_'.$data['newpage']->id.$year.'-'.$month_str, $count, 'news_archive'); } $data['archives'][$year][$month_str] = $count; $month_count = $month_count + $count; } /*if($year == date('Y') && $month_str == date('m')){ break; }*/ } if($month_count == 0){ unset($data['archives'][$year]); } } } } //マルチギャラリーの場合 }elseif($data['newpage']->pagetype_id == 12){ $query->contain(['MultigalleryCategories']); // /*$data['categories'] = $this->MultigalleryCategories->find() ->where(['MultigalleryCategories.company_id' => $company->id]) ->where(['MultigalleryCategories.multigallery_id' => $data['newpage']->id]) ->where(['MultigalleryCategories.display_flag' => 1]) ->where(['MultigalleryCategories.delete_flag' => 0]) ->order(['sort' => 'ASC']) ->all();*/ $data['categories']['parent'] = $this->MultigalleryCategories->find() ->where(['MultigalleryCategories.company_id' => $company->id]) //->where(['MultigalleryCategories.parent_id IS NULL']) ->where(['OR' => [['MultigalleryCategories.parent_id' => 0], ['MultigalleryCategories.parent_id IS NULL']]]) ->where(['MultigalleryCategories.multigallery_id' => $data['newpage']->id]) ->where(['MultigalleryCategories.display_flag' => 1]) ->where(['MultigalleryCategories.delete_flag' => 0]) ->order(['sort' => 'ASC']) ->all(); $data['categories']['child'] = []; foreach($data['categories']['parent'] as $mg_parent){ $tmp_mg_childs = ''; $tmp_mg_childs = $this->MultigalleryCategories->find() ->where(['MultigalleryCategories.company_id' => $company->id]) ->where(['MultigalleryCategories.parent_id' => $mg_parent->id]) ->where(['MultigalleryCategories.multigallery_id' => $data['newpage']->id]) ->where(['MultigalleryCategories.display_flag' => 1]) ->where(['MultigalleryCategories.delete_flag' => 0]) ->order(['sort' => 'ASC']) ->all(); if(!empty($tmp_mg_childs)){ $data['categories']['child'][$mg_parent->id] = $tmp_mg_childs; foreach($tmp_mg_childs as $tmp_mg_child){ $tmp_mg_grandchilds = ''; $tmp_mg_grandchilds = $this->MultigalleryCategories->find() ->where(['MultigalleryCategories.company_id' => $company->id]) ->where(['MultigalleryCategories.parent_id' => $tmp_mg_child->id]) ->where(['MultigalleryCategories.multigallery_id' => $data['newpage']->id]) ->where(['MultigalleryCategories.display_flag' => 1]) ->where(['MultigalleryCategories.delete_flag' => 0]) ->order(['sort' => 'ASC']) ->all(); if(!empty($tmp_mg_grandchilds)){ $data['categories']['child'][$tmp_mg_child->id] = $tmp_mg_grandchilds; // foreach($tmp_mg_grandchilds as $tmp_mg_grandchild){ // $tmp_mg_grandchilds2 = ''; $tmp_mg_grandchilds2 = $this->MultigalleryCategories->find() ->where(['MultigalleryCategories.company_id' => $company->id]) ->where(['MultigalleryCategories.parent_id' => $tmp_mg_grandchild->id]) ->where(['MultigalleryCategories.multigallery_id' => $data['newpage']->id]) ->where(['MultigalleryCategories.display_flag' => 1]) ->where(['MultigalleryCategories.delete_flag' => 0]) ->order(['sort' => 'ASC']) ->all(); if(!empty($tmp_mg_grandchilds2)){ $data['categories']['grandchild'][$tmp_mg_grandchild->id] = $tmp_mg_grandchilds2; } } // } } } } $data['tags'] = $this->Tags->find() ->where(['Tags.company_id' => $company->id]) //->where(['Tags.column_id' => $tmp_page_id]) ->where(['Tags.display_flag' => 1]) ->where(['Tags.delete_flag' => 0]) ->order(['sort' => 'ASC']) ->all(); $data['resent_posts'] = $this->Newpages->find() ->where(['Newpages.company_id' => $company->id]) ->where(['Newpages.parent_id' => $data['newpage']->id]) ->where(['Newpages.pagetype_id' => 6]) ->where(['Newpages.display_flag' => 1]) ->where(['Newpages.delete_flag' => 0]) ->where(['Newpages.release_date <=' => date('Y-m-d H:i:s')]) //->order(['Newpages.release_date' => 'DESC']) ->order(['Newpages.release_date' => 'DESC', 'Newpages.id' => 'DESC']) ->limit(3) ->all(); //カテゴリやタグの絞り込み if($fixed_slug == 'category'){ /*$query->matching('ColumnCategories', function($q)use($tag_category){ return $q->where(['ColumnCategories.name' => urldecode($tag_category)]); });*/ // $data['parent_category'] = $this->MultigalleryCategories->find() ->where(['MultigalleryCategories.company_id' => $company->id]) ->where(['MultigalleryCategories.multigallery_id' => $data['newpage']->id]) ->where(['MultigalleryCategories.name' => urldecode($tag_category)]) ->first(); if(empty($data['parent_category'])){ return $this->redirect('404.html', '301'); }else{ $multigallery_parent_id = $data['parent_category']->id; } if($data['newpage']->pagetype_id == 12 && $data['others']['archive_cache'] == 1 && $fixed_slug == 'category' && ($multigallery_archive_cache = Cache::read($company->id.'_'.$data['parent_category']->id.'_'.$offset, 'multigallery_category_archive')) !== false){ // $data['articles'] = $multigallery_archive_cache['articles']; $article_count = $multigallery_archive_cache['article_count']; $limit = $multigallery_archive_cache['limit']; $total_result = $multigallery_archive_cache['total_result']; $result_start = $multigallery_archive_cache['result_start']; $result_end = $multigallery_archive_cache['result_end']; } $query->matching('MultigalleryCategories', function($q)use($multigallery_parent_id){ return $q->where(['MultigalleryCategories.id' => $multigallery_parent_id]); }); //※※※ $data['tmp_layer'] = $slug_plus.'category/'.urldecode($tag_category).'/'; if(!empty($data['parent_category']->h1_text)){ $data['newpage']->h1_text = $data['parent_category']->h1_text; } }elseif($fixed_slug == 'tag'){ //multigallery用のタグではなく、Page用のタグを用いる /*$query->matching('Tags', function($q)use($tag_category){ return $q->where(['Tags.name' => urldecode($tag_category)]); });*/ // $tmp_tag = $this->Tags->find() ->where(['Tags.company_id' => $company->id]) ->where(['Tags.name' => urldecode($tag_category)]) ->first(); if(empty($tmp_tag)){ return $this->redirect('404.html', '301'); } // /*$query->matching('Tags', function($q)use($tag_category) { //return $q->where(['ColumnCategories.slug' => $tag_category]); return $q->where(['Tags.name' => urldecode($tag_category)]); });*/ $tmp_tag_id = $tmp_tag->id; $query->matching('Tags', function($q)use($tmp_tag_id) { //return $q->where(['ColumnCategories.slug' => $tag_category]); return $q->where(['Tags.id' => $tmp_tag_id]); }); // $data['parent_tag'] = $this->Tags->find() ->where(['Tags.company_id' => $company->id]) ->where(['Tags.name' => urldecode($tag_category)]) ->first(); } //年月アーカイブリンク用のデータ取得 if($data['others']['other3'] == 1){ //一番古い記事を取得 $oldest_page = $this->Newpages->find() ->where(['Newpages.company_id' => $company->id]) ->where(['Newpages.parent_id' => $data['newpage']->id]) ->where(['Newpages.pagetype_id' => 6]) ->where(['Newpages.display_flag' => 1]) ->where(['Newpages.release_date <=' => date('Y-m-d H:i:s')]) ->where(['Newpages.delete_flag' => 0]) ->order(['Newpages.release_date' => 'ASC']) ->first(); $data['archives'] = []; if(!empty($oldest_page)){ $oldest_year = $oldest_page->release_date->format('Y'); for($year=date('Y');$year>=$oldest_year;$year--){ $data['archives'][$year] = []; $month_count = 0; for($month=12;$month>=1;$month--){ if($year == date('Y') && $month > date('n')){ }else{ $month_str = sprintf("%02d",$month); $count = 0; if(($count = Cache::read($company->id.'_multigallery_'.$data['newpage']->id.$year.'-'.$month_str, 'multigallery_archive')) === false){ $count = $this->Newpages->find() ->where(['Newpages.company_id' => $company->id]) ->where(['Newpages.parent_id' => $data['newpage']->id]) ->where(['Newpages.pagetype_id' => 6]) ->where(['Newpages.display_flag' => 1]) //->where(['Pages.release_date <=' => date('Y-m-d H:i:s')]) ->where(['AND' => [['Newpages.release_date <=' => date('Y-m-d H:i:s')], ['Newpages.release_date LIKE' => $year.'-'.$month_str.'%']]]) ->where(['Newpages.delete_flag' => 0]) ->order(['release_date' => 'DESC']) ->count(); //キャッシュの書き込み Cache::write($company->id.'_multigallery_'.$data['newpage']->id.$year.'-'.$month_str, $count, 'multigallery_archive'); } $data['archives'][$year][$month_str] = $count; $month_count = $month_count + $count; } } if($month_count == 0){ unset($data['archives'][$year]); } } } } }else{ $limit = 10; } $query->limit($limit); //件数やページ数のセット if(!empty($page_num)){ $offset = ($limit * $page_num) - $limit; $query->offset($offset); } //カテゴリやタグの絞り込み /* if($fixed_slug == 'category'){ $article_category = urldecode($tag_category); if($data['page']->pagetype_id == 2){ $query->matching('BlogCategories', function($q)use($tag_category) { //return $q->where(['BlogCategories.slug' => $tag_category]); return $q->where(['BlogCategories.name' => urldecode($tag_category)]); }); }elseif($data['page']->pagetype_id == 3){ $query->matching('NewsCategories', function($q)use($tag_category) { //return $q->where(['NewsCategories.slug' => $tag_category]); return $q->where(['NewsCategories.name' => urldecode($tag_category)]); }); } }elseif($fixed_slug == 'tag'){ $article_tag = urldecode($tag_category); $query->matching('BlogTags', function($q)use($tag_category) { //return $q->where(['BlogCategories.slug' => $tag_category]); return $q->where(['BlogTags.name' => urldecode($tag_category)]); }); }*/ if($data['newpage']->pagetype_id == 2 && $data['others']['archive_cache'] == 1 && ($blog_archive_cache = Cache::read($company->id.'_'.$data['parent_category']->id.'_'.$offset, 'blog_category_archive')) === false){ $article_count = $query->count(); // $total_result = $article_count; $result_start = $offset + 1; $result_end = $offset + $limit; if($result_end > $total_result){ $result_end = $total_result; } /*$this->set('total_result', $total_result); $this->set('result_start', $result_start); $this->set('result_end', $result_end);*/ // $articles = $query->all(); $data['articles'] = $articles; // $blog_archive_cache = []; $blog_archive_cache['articles'] = $data['articles']; $blog_archive_cache['article_count'] = $article_count; $blog_archive_cache['limit'] = $limit; $blog_archive_cache['total_result'] = $total_result; $blog_archive_cache['result_start'] = $result_start; $blog_archive_cache['result_end'] = $result_end; //キャッシュの書き込み if($fixed_slug == 'category'){ Cache::write($company->id.'_'.$data['parent_category']->id.'_'.$offset, $blog_archive_cache, 'blog_category_archive'); } }elseif($data['newpage']->pagetype_id == 12 && $data['others']['archive_cache'] == 1 && ($multigallery_archive_cache = Cache::read($company->id.'_'.$data['parent_category']->id.'_'.$offset, 'multigallery_category_archive')) === false){ $article_count = $query->count(); // $total_result = $article_count; $result_start = $offset + 1; $result_end = $offset + $limit; if($result_end > $total_result){ $result_end = $total_result; } /*$this->set('total_result', $total_result); $this->set('result_start', $result_start); $this->set('result_end', $result_end);*/ // $articles = $query->all(); $data['articles'] = $articles; // $multigallery_archive_cache = []; $multigallery_archive_cache['articles'] = $data['articles']; $multigallery_archive_cache['article_count'] = $article_count; $multigallery_archive_cache['limit'] = $limit; $multigallery_archive_cache['total_result'] = $total_result; $multigallery_archive_cache['result_start'] = $result_start; $multigallery_archive_cache['result_end'] = $result_end; //キャッシュの書き込み if($fixed_slug == 'category'){ Cache::write($company->id.'_'.$data['parent_category']->id.'_'.$offset, $multigallery_archive_cache, 'multigallery_category_archive'); } }elseif(!isset($data['others']['archive_cache']) || $data['others']['archive_cache'] == 0){ $article_count = $query->count(); // $total_result = $article_count; $result_start = $offset + 1; $result_end = $offset + $limit; if($result_end > $total_result){ $result_end = $total_result; } // $articles = $query->all(); $data['articles'] = $articles; }else{ } //ページネーション /*if(($count / $limit) > 0 && $count > 0){ $data['pagenation'] = $this->pagenation_data($page_num, $count, $limit); }*/ // /*if($data['setting']->webp_flag == 2){ $this->viewBuilder()->layout('newframe_webp/archive'); }else{ $this->viewBuilder()->layout('newframe/archive'); }*/ // $this->set('total_result', $total_result); $this->set('result_start', $result_start); $this->set('result_end', $result_end); //ページネーション if(($article_count / $limit) > 0 && $article_count > 0){ $data['pagenation'] = $this->pagenation_data($page_num, $article_count, $limit); } // if($data['setting']->webp_flag == 2){ $this->viewBuilder()->layout('newframe_webp/archive'); }else{ $this->viewBuilder()->layout('newframe/archive'); } //ブログ・新着情報記事の場合 }elseif(isset($data['newpage']) && $data['newpage']->pagetype_id == 6){ //※※※暫定対策 $data['detail_title'] = $data['newpage']->title; // $data['parent_page'] = $this->Newpages->find() ->where(['Newpages.company_id' => $company->id]) ->where(['Newpages.id' => $data['newpage']->parent_id]) ->where(['Newpages.display_flag' => 1]) ->where(['Newpages.delete_flag' => 0]) ->order(['release_date' => 'DESC']) ->first(); if(empty($data['parent_page'])){ return $this->redirect('404.html', '301'); } $data['parent_entries'] = json_decode($data['parent_page']->entries, true); $data['parent_headers'] = json_decode($data['parent_page']->headers, true); $data['parent_footers'] = json_decode($data['parent_page']->footers, true); $data['parent_others'] = json_decode($data['parent_page']->others, true); $data['parent_images'] = json_decode($data['parent_page']->images, true); // $data['resent_posts'] = $this->Newpages->find() ->where(['Newpages.company_id' => $company->id]) ->where(['Newpages.parent_id' => $data['parent_page']->id]) ->where(['Newpages.pagetype_id' => 6]) ->where(['Newpages.display_flag' => 1]) ->where(['Newpages.delete_flag' => 0]) ->where(['Newpages.release_date <=' => date('Y-m-d H:i:s')]) //->order(['Newpages.release_date' => 'DESC']) ->order(['Newpages.release_date' => 'DESC', 'Newpages.id' => 'DESC']) ->limit(3) ->all(); //レコメンド if($data['parent_page']->recommend_flag == 1){ /* // $data['recommends'] = ''; //キーワード上位3件で取得を試みる if(!empty($data['newpage']->recommend01) && !empty($data['newpage']->recommend02) && !empty($data['newpage']->recommend03)){ $sql = 'SELECT *, MATCH(ameblo_content) AGAINST ("'.$data['newpage']->recommend01.' '.$data['newpage']->recommend02.' '.$data['newpage']->recommend03.'" IN BOOLEAN MODE) AS relevance FROM `newpages` WHERE MATCH(ameblo_content) AGAINST ("'.$data['newpage']->recommend01.' '.$data['newpage']->recommend02.' '.$data['newpage']->recommend03.'" IN BOOLEAN MODE) and company_id = '.$company->id.' limit 10;'; $connection = ConnectionManager::get('default'); $recommends = $connection->execute($sql)->fetch('assoc'); var_dump($sql); var_dump($recommends); }elseif(!empty($data['newpage']->recommend01) && !empty($data['newpage']->recommend02)){ }elseif(!empty($data['newpage']->recommend01)){ }else{ }*/ // $data['recommends'] = ''; // $count = $this->Newpages->find() ->where(['Newpages.id IS NOT' => $data['newpage']->id]) ->where(['Newpages.company_id' => $company->id]) ->where(['Newpages.parent_id' => $data['parent_page']->id]) ->where(['Newpages.pagetype_id' => 6]) ->where(['Newpages.release_date <=' => date('Y-m-d H:i:s')]) ->where(['Newpages.display_flag' => 1]) ->where(['AND' => [ ['Newpages.ameblo_content LIKE' => '%'.$data['newpage']->recommend01.'%'], ['Newpages.ameblo_content LIKE' => '%'.$data['newpage']->recommend02.'%'], ['Newpages.ameblo_content LIKE' => '%'.$data['newpage']->recommend03.'%'], ]]) ->where(['Newpages.delete_flag' => 0]) ->order(['release_date' => 'DESC']) ->count(); if($count < 4){ $count = $this->Newpages->find() ->where(['Newpages.id IS NOT' => $data['newpage']->id]) ->where(['Newpages.company_id' => $company->id]) ->where(['Newpages.parent_id' => $data['parent_page']->id]) ->where(['Newpages.pagetype_id' => 6]) ->where(['Newpages.release_date <=' => date('Y-m-d H:i:s')]) ->where(['Newpages.display_flag' => 1]) ->where(['AND' => [ ['Newpages.ameblo_content LIKE' => '%'.$data['newpage']->recommend01.'%'], ['Newpages.ameblo_content LIKE' => '%'.$data['newpage']->recommend02.'%'], ]]) ->where(['Newpages.delete_flag' => 0]) ->order(['release_date' => 'DESC']) ->count(); if($count < 4){ $data['recommends'] = $this->Newpages->find() ->where(['Newpages.id IS NOT' => $data['newpage']->id]) ->where(['Newpages.company_id' => $company->id]) ->where(['Newpages.parent_id' => $data['parent_page']->id]) ->where(['Newpages.pagetype_id' => 6]) ->where(['Newpages.release_date <=' => date('Y-m-d H:i:s')]) ->where(['Newpages.display_flag' => 1]) ->where(['AND' => [ ['Newpages.ameblo_content LIKE' => '%'.$data['newpage']->recommend01.'%'], ]]) ->where(['Newpages.delete_flag' => 0]) ->order(['release_date' => 'DESC']) ->all(); }else{ $data['recommends'] = $this->Newpages->find() ->where(['Newpages.id IS NOT' => $data['newpage']->id]) ->where(['Newpages.company_id' => $company->id]) ->where(['Newpages.parent_id' => $data['parent_page']->id]) ->where(['Newpages.pagetype_id' => 6]) ->where(['Newpages.release_date <=' => date('Y-m-d H:i:s')]) ->where(['Newpages.display_flag' => 1]) ->where(['AND' => [ ['Newpages.ameblo_content LIKE' => '%'.$data['newpage']->recommend01.'%'], ['Newpages.ameblo_content LIKE' => '%'.$data['newpage']->recommend02.'%'], ]]) ->where(['Newpages.delete_flag' => 0]) ->order(['release_date' => 'DESC']) ->all(); } }else{ $data['recommends'] = $this->Newpages->find() ->where(['Newpages.id IS NOT' => $data['newpage']->id]) ->where(['Newpages.company_id' => $company->id]) ->where(['Newpages.parent_id' => $data['parent_page']->id]) ->where(['Newpages.pagetype_id' => 6]) ->where(['Newpages.release_date <=' => date('Y-m-d H:i:s')]) ->where(['Newpages.display_flag' => 1]) ->where(['AND' => [ ['Newpages.ameblo_content LIKE' => '%'.$data['newpage']->recommend01.'%'], ['Newpages.ameblo_content LIKE' => '%'.$data['newpage']->recommend02.'%'], ['Newpages.ameblo_content LIKE' => '%'.$data['newpage']->recommend03.'%'], ]]) ->where(['Newpages.delete_flag' => 0]) ->order(['release_date' => 'DESC']) ->all(); } } //年月アーカイブリンク用のデータ取得 if($data['parent_others']['other3'] == 1){ //一番古い記事を取得 $oldest_page = $this->Newpages->find() ->where(['Newpages.company_id' => $company->id]) ->where(['Newpages.parent_id' => $data['parent_page']->id]) ->where(['Newpages.pagetype_id' => 6]) ->where(['Newpages.display_flag' => 1]) ->where(['Newpages.release_date <=' => date('Y-m-d H:i:s')]) ->where(['Newpages.delete_flag' => 0]) ->order(['release_date' => 'ASC']) ->first(); $data['archives'] = []; if(!empty($oldest_page)){ $oldest_year = $oldest_page->release_date->format('Y'); for($year=date('Y');$year>=$oldest_year;$year--){ $data['archives'][$year] = []; $month_count = 0; for($month=12;$month>=1;$month--){ if($year == date('Y') && $month > date('n')){ }else{ $month_str = sprintf("%02d",$month); $count = 0; if(($count = Cache::read($company->id.'_blog_'.$year.'-'.$month_str, 'blog_archive')) === false){ $count = $this->Newpages->find() ->where(['Newpages.company_id' => $company->id]) ->where(['Newpages.parent_id' => $data['newpage']->id]) ->where(['Newpages.pagetype_id' => 6]) ->where(['Newpages.display_flag' => 1]) //->where(['Pages.release_date <=' => date('Y-m-d H:i:s')]) ->where(['AND' => [['Newpages.release_date <=' => date('Y-m-d H:i:s')], ['Newpages.release_date LIKE' => $year.'-'.$month_str.'%']]]) ->where(['Newpages.delete_flag' => 0]) ->order(['release_date' => 'DESC']) ->count(); //キャッシュの書き込み Cache::write($company->id.'_blog_'.$year.'-'.$month_str, $count, 'blog_archive'); } $data['archives'][$year][$month_str] = $count; $month_count = $month_count + $count; } } if($month_count == 0){ unset($data['archives'][$year]); } } } } //カテゴリ if($data['parent_page']->pagetype_id == 2){ // $data['categories'] = $this->BlogCategories->find() ->where(['BlogCategories.company_id' => $company->id]) ->where(['BlogCategories.blog_id' => $data['parent_page']->id]) ->where(['BlogCategories.display_flag' => 1]) ->where(['BlogCategories.delete_flag' => 0]) ->order(['sort' => 'ASC']) ->all(); $data['tags'] = $this->Tags->find() ->where(['Tags.company_id' => $company->id]) //->where(['Tags.blog_id' => $tmp_page_id]) ->where(['Tags.display_flag' => 1]) ->where(['Tags.delete_flag' => 0]) ->order(['sort' => 'ASC']) ->all(); // $data['next_page'] = $this->Newpages->find() ->select(['Newpages.id', 'Newpages.slug', 'Newpages.name']) ->where(['Newpages.company_id' => $company->id]) ->where(['Newpages.parent_id' => $data['newpage']->parent_id]) ->where(['Newpages.pagetype_id' => 6, 'AND' => [['Newpages.release_date >=' => $data['newpage']->release_date->format('Y-m-d H:i:s')], ['Newpages.release_date <=' => date('Y-m-d H:i:s')]]]) //->where(['Newpages.id' => $data['newpage']->id]) ->where(['NOT' => ['Newpages.id' => $data['newpage']->id]]) //->where(['Pages.release_date >=' => $data['newpage']->release_date]) ->where(['Newpages.display_flag' => 1]) ->where(['Newpages.delete_flag' => 0]) //->order(['release_date' => 'ASC', 'id' => 'DESC']) ->order(['release_date' => 'ASC']) ->first(); $data['prev_page'] = $this->Newpages->find() ->select(['Newpages.id', 'Newpages.slug', 'Newpages.name']) ->where(['Newpages.company_id' => $company->id]) ->where(['Newpages.parent_id' => $data['newpage']->parent_id]) ->where(['Newpages.pagetype_id' => 6, 'AND' => [['Newpages.release_date <=' => $data['newpage']->release_date->format('Y-m-d H:i:s')], ['Newpages.release_date <=' => date('Y-m-d H:i:s')]]]) //->where(['Newpages.id' => $data['newpage']->id]) ->where(['NOT' => ['Newpages.id' => $data['newpage']->id]]) //->where(['Newpages.release_date <=' => $data['newpage']->release_date]) ->where(['Newpages.display_flag' => 1]) ->where(['Newpages.delete_flag' => 0]) //->order(['id' => 'DESC', 'release_date' => 'DESC']) ->order(['release_date' => 'DESC']) ->first(); }elseif($data['parent_page']->pagetype_id == 5){ // $data['categories'] = $this->ColumnCategories->find() ->where(['ColumnCategories.company_id' => $company->id]) ->where(['ColumnCategories.column_id' => $data['parent_page']->id]) ->where(['ColumnCategories.display_flag' => 1]) ->where(['ColumnCategories.delete_flag' => 0]) ->order(['sort' => 'ASC']) ->all(); $data['tags'] = $this->Tags->find() ->where(['Tags.company_id' => $company->id]) //->where(['Tags.blog_id' => $tmp_page_id]) ->where(['Tags.display_flag' => 1]) ->where(['Tags.delete_flag' => 0]) ->order(['sort' => 'ASC']) ->all(); // $data['next_page'] = $this->Newpages->find() ->select(['Newpages.id', 'Newpages.slug', 'Newpages.name']) ->where(['Newpages.company_id' => $company->id]) ->where(['Newpages.parent_id' => $data['newpage']->parent_id]) ->where(['Newpages.pagetype_id' => 6, 'AND' => [['Newpages.release_date >=' => $data['newpage']->release_date->format('Y-m-d H:i:s')], ['Newpages.release_date <=' => date('Y-m-d H:i:s')]]]) //->where(['Newpages.id' => $data['newpage']->id]) ->where(['NOT' => ['Newpages.id' => $data['newpage']->id]]) //->where(['Pages.release_date >=' => $data['newpage']->release_date]) ->where(['Newpages.display_flag' => 1]) ->where(['Newpages.delete_flag' => 0]) //->order(['release_date' => 'ASC', 'id' => 'DESC']) ->order(['release_date' => 'ASC']) ->first(); $data['prev_page'] = $this->Newpages->find() ->select(['Newpages.id', 'Newpages.slug', 'Newpages.name']) ->where(['Newpages.company_id' => $company->id]) ->where(['Newpages.parent_id' => $data['newpage']->parent_id]) ->where(['Newpages.pagetype_id' => 6, 'AND' => [['Newpages.release_date <=' => $data['newpage']->release_date->format('Y-m-d H:i:s')], ['Newpages.release_date <=' => date('Y-m-d H:i:s')]]]) //->where(['Newpages.id' => $data['newpage']->id]) ->where(['NOT' => ['Newpages.id' => $data['newpage']->id]]) //->where(['Newpages.release_date <=' => $data['newpage']->release_date]) ->where(['Newpages.display_flag' => 1]) ->where(['Newpages.delete_flag' => 0]) //->order(['id' => 'DESC', 'release_date' => 'DESC']) ->order(['release_date' => 'DESC']) ->first(); }elseif($data['parent_page']->pagetype_id == 3){ // $data['categories'] = $this->NewsCategories->find() ->where(['NewsCategories.company_id' => $company->id]) ->where(['NewsCategories.news_id' => $data['parent_page']->id]) ->where(['NewsCategories.display_flag' => 1]) ->where(['NewsCategories.delete_flag' => 0]) ->order(['sort' => 'ASC']) ->all(); // $data['next_page'] = $this->Newpages->find() ->select(['Newpages.id', 'Newpages.slug', 'Newpages.name']) ->where(['Newpages.company_id' => $company->id]) ->where(['Newpages.parent_id' => $data['newpage']->parent_id]) ->where(['Newpages.pagetype_id' => 6, 'AND' => [['Newpages.release_date >=' => $data['newpage']->release_date->format('Y-m-d H:i:s')], ['Newpages.release_date <=' => date('Y-m-d H:i:s')]]]) //->where(['Newpages.id' => $data['newpage']->id]) ->where(['NOT' => ['Newpages.id' => $data['newpage']->id]]) ->where(['Newpages.release_date >=' => $data['newpage']->release_date]) ->where(['Newpages.display_flag' => 1]) ->where(['Newpages.delete_flag' => 0]) ->order(['release_date' => 'ASC']) ->first(); $data['prev_page'] = $this->Newpages->find() ->select(['Newpages.id', 'Newpages.slug', 'Newpages.name']) ->where(['Newpages.company_id' => $company->id]) ->where(['Newpages.parent_id' => $data['newpage']->parent_id]) ->where(['Newpages.pagetype_id' => 6, 'AND' => [['Newpages.release_date <=' => $data['newpage']->release_date->format('Y-m-d H:i:s')], ['Newpages.release_date <=' => date('Y-m-d H:i:s')]]]) //->where(['Newpages.id' => $data['newpage']->id]) ->where(['NOT' => ['Newpages.id' => $data['newpage']->id]]) ->where(['Newpages.release_date <=' => $data['newpage']->release_date]) ->where(['Newpages.display_flag' => 1]) ->where(['Newpages.delete_flag' => 0]) ->order(['release_date' => 'DESC']) ->first(); }elseif($data['parent_page']->pagetype_id == 12){ // /*$data['categories'] = $this->MultigalleryCategories->find() ->where(['MultigalleryCategories.company_id' => $company->id]) ->where(['MultigalleryCategories.multigallery_id' => $data['parent_page']->id]) ->where(['MultigalleryCategories.display_flag' => 1]) ->where(['MultigalleryCategories.delete_flag' => 0]) ->order(['sort' => 'ASC']) ->all();*/ // $data['categories']['parent'] = $this->MultigalleryCategories->find() ->where(['MultigalleryCategories.company_id' => $company->id]) //->where(['MultigalleryCategories.parent_id IS NULL']) ->where(['OR' => [['MultigalleryCategories.parent_id' => 0], ['MultigalleryCategories.parent_id IS NULL']]]) ->where(['MultigalleryCategories.multigallery_id' => $data['parent_page']->id]) ->where(['MultigalleryCategories.display_flag' => 1]) ->where(['MultigalleryCategories.delete_flag' => 0]) ->order(['sort' => 'ASC']) ->all(); $data['categories']['child'] = []; foreach($data['categories']['parent'] as $mg_parent){ $tmp_mg_childs = ''; $tmp_mg_childs = $this->MultigalleryCategories->find() ->where(['MultigalleryCategories.company_id' => $company->id]) ->where(['MultigalleryCategories.parent_id' => $mg_parent->id]) ->where(['MultigalleryCategories.multigallery_id' => $data['parent_page']->id]) ->where(['MultigalleryCategories.display_flag' => 1]) ->where(['MultigalleryCategories.delete_flag' => 0]) ->order(['sort' => 'ASC']) ->all(); if(!empty($tmp_mg_childs)){ $data['categories']['child'][$mg_parent->id] = $tmp_mg_childs; foreach($tmp_mg_childs as $tmp_mg_child){ $tmp_mg_grandchilds = ''; $tmp_mg_grandchilds = $this->MultigalleryCategories->find() ->where(['MultigalleryCategories.company_id' => $company->id]) ->where(['MultigalleryCategories.parent_id' => $tmp_mg_child->id]) ->where(['MultigalleryCategories.multigallery_id' => $data['parent_page']->id]) ->where(['MultigalleryCategories.display_flag' => 1]) ->where(['MultigalleryCategories.delete_flag' => 0]) ->order(['sort' => 'ASC']) ->all(); if(!empty($tmp_mg_grandchilds)){ $data['categories']['child'][$tmp_mg_child->id] = $tmp_mg_grandchilds; } } } } $data['tags'] = $this->Tags->find() ->where(['Tags.company_id' => $company->id]) //->where(['Tags.blog_id' => $tmp_page_id]) ->where(['Tags.display_flag' => 1]) ->where(['Tags.delete_flag' => 0]) ->order(['sort' => 'ASC']) ->all(); // $data['next_page'] = $this->Newpages->find() ->select(['Newpages.id', 'Newpages.slug', 'Newpages.name']) ->where(['Newpages.company_id' => $company->id]) ->where(['Newpages.parent_id' => $data['newpage']->parent_id]) ->where(['Newpages.pagetype_id' => 6, 'AND' => [['Newpages.release_date >=' => $data['newpage']->release_date->format('Y-m-d H:i:s')], ['Newpages.release_date <=' => date('Y-m-d H:i:s')]]]) //->where(['Newpages.id' => $data['newpage']->id]) ->where(['NOT' => ['Newpages.id' => $data['newpage']->id]]) //->where(['Pages.release_date >=' => $data['newpage']->release_date]) ->where(['Newpages.display_flag' => 1]) ->where(['Newpages.delete_flag' => 0]) //->order(['release_date' => 'ASC', 'id' => 'DESC']) ->order(['release_date' => 'ASC']) ->first(); $data['prev_page'] = $this->Newpages->find() ->select(['Newpages.id', 'Newpages.slug', 'Newpages.name']) ->where(['Newpages.company_id' => $company->id]) ->where(['Newpages.parent_id' => $data['newpage']->parent_id]) ->where(['Newpages.pagetype_id' => 6, 'AND' => [['Newpages.release_date <=' => $data['newpage']->release_date->format('Y-m-d H:i:s')], ['Newpages.release_date <=' => date('Y-m-d H:i:s')]]]) //->where(['Newpages.id' => $data['newpage']->id]) ->where(['NOT' => ['Newpages.id' => $data['newpage']->id]]) //->where(['Newpages.release_date <=' => $data['newpage']->release_date]) ->where(['Newpages.display_flag' => 1]) ->where(['Newpages.delete_flag' => 0]) //->order(['id' => 'DESC', 'release_date' => 'DESC']) ->order(['release_date' => 'DESC']) ->first(); } //記事ページのタイトル if(empty($data['setting']->seo_title)){ if($data['parent_others']['other4'] == 1){ $data['newpage']->title = $data['newpage']->title.' | '.$data['parent_page']->title; } } $data['html'] = $data['newpage']->html; preg_match_all('/{newblock_id:(.*?)}/s', $data['html'], $newblock_ids); // if($fixed_slug == 'form_conf' || $fixed_slug == 'form_send'){ foreach($newblock_ids[1] as $key=>$newblock_id){ $html = ''; if($newblock_id == $form_block_id){ $html = $this->blockToHtml($company->id, $company->subdomain, $newblock_id, $slug_plus, $fixed_slug, '', $data['setting']->logo_image, $contact_gallery_id, $company->cms_version, $contact_recruit_id, '', ''); } $data['html'] = str_replace($newblock_ids[0][$key], $html, $data['html']); } }else{ foreach($newblock_ids[1] as $key=>$newblock_id){ $html = ''; $html = $this->blockToHtml($company->id, $company->subdomain, $newblock_id, $slug_plus, $fixed_slug, '', $data['setting']->logo_image, $contact_gallery_id, $company->cms_version, $contact_recruit_id, '', ''); $data['html'] = str_replace($newblock_ids[0][$key], $html, $data['html']); } } //辞書機能 if(isset($data['html']) && !empty($data['html']) && $data['setting']->dictionary_mode != 2){ $data['html'] = $this->new_dictionary_data($company->id, $slug, $data['html'], $data['setting']->dictionary_mode, $data['setting']->dictionary_tooltip); } //パンくずリストの対応 if(empty($data['breadcrumb'][3]['name'])){ $data['breadcrumb'][3]['name'] = mb_strimwidth($data['newpage']->ameblo_content, 0, 20, "…", "UTF-8"); } // if($data['setting']->webp_flag == 2){ $this->viewBuilder()->layout('newframe_webp/detail'); }else{ $this->viewBuilder()->layout('newframe/detail'); } //ギャラリー一覧の場合 }elseif(isset($data['newpage']) && $data['newpage']->pagetype_id == 8){ //後から追加した機能、ギャラリーの枠として使用されているページのデータ取得 $tmp_reference_page_query = $this->Newpages->find() ->where(['Newpages.company_id' => $company->id]) ->where(['Newpages.pagetype_id' => 8]) ->where(['Newpages.delete_flag' => 0]); //->first(); if(!empty($data['newpage']->page_kind)){ $tmp_reference_page_query->where(['Newpages.page_kind' => $data['newpage']->page_kind]); }else{ $tmp_reference_page_query->where(['OR' => [['Newpages.page_kind' => ''], ['Newpages.page_kind IS NULL']]]); } $tmp_reference_page = $tmp_reference_page_query->first(); //カテゴリ分け表示、一括表示の分岐 //一括表示の場合 //if($slug == 'all'){ /*if($slug == 'all'){ //全カテゴリカテゴリのデータ取得 $query = $this->Galleries->find() ->contain(['GalleryCategories']) ->where(['Galleries.company_id' => $company_data->id]) //->where(['Galleries.gallery_category_id IN' => $category_id_array]) ->where(['Galleries.display_flag' => 1]) ->where(['Galleries.delete_flag' => 0]) //gallery_archiveの暫定対策 ->where(['GalleryCategories.gallery_kind IS NULL']); //->order(['Galleries.sort' => 'ASC']); //->order(['GalleryCategories.sort' => 'ASC', 'Galleries.sort' => 'ASC']); if($tmp_reference_page->sort_flag == 1){ //$query->order(['GalleryCategories.sort' => 'ASC', 'Galleries.sort' => 'DESC']); $query->order(['Galleries.sort' => 'DESC']); }else{ //$query->order(['GalleryCategories.sort' => 'ASC', 'Galleries.sort' => 'ASC']); $query->order(['Galleries.sort' => 'ASC']); } //->order(['release_date' => 'DESC']) // if(isset($data['setting']->gallery_archive_title) && !empty($data['setting']->gallery_archive_title)){ $slug == $data['setting']->gallery_archive_title; $data['gallery_category'] = new \stdClass; $data['gallery_category']->name = $data['setting']->gallery_archive_title; //$data['gallery_category']->abbr = $data['setting']->gallery_archive_title; }else{ $slug == '全てを表示'; $data['gallery_category'] = new \stdClass; $data['gallery_category']->name = '全てを表示'; //$data['gallery_category']->abbr = '全てを表示'; } //カテゴリ一覧 $data['gallery_categories'] = $this->GalleryCategories->find() ->select(['GalleryCategories.name', 'GalleryCategories.abbr']) ->where(['GalleryCategories.company_id' => $company_data->id]) ->where(['GalleryCategories.display_flag' => 1]) ->where(['GalleryCategories.delete_flag' => 0]) ->order(['GalleryCategories.sort' => 'ASC']) //gallery_archiveの暫定対策 ->where(['GalleryCategories.gallery_kind IS NULL']) ->all(); // //$data['tmp_layer'] = '/'.$slug.'/gallery_archive/'; //$data['tmp_layer'] = '/gallery_archive/'; $data['tmp_layer'] = '/gallery_archive/all/';*/ //後から追加した機能、ギャラリーの枠として //}elseif($data['page']->pagetype_id == '8' && ($page_mode != 'gallery_archive' || $fixed_slug == 'detail')){ if($data['newpage']->pagetype_id == '8' && ($page_mode != 'gallery_archive' || $fixed_slug == 'detail' || $fixed_slug2 == 'detail')){ //詳細 if($fixed_slug == 'detail' || $fixed_slug2 == 'detail'){ $data['gallery'] = $this->Galleries->find() ->contain(['GalleryCategories']) ->where(['Galleries.id' => $tag_category]) ->where(['Galleries.company_id' => $company->id]) ->where(['Galleries.display_flag' => 1]) ->where(['Galleries.delete_flag' => 0]) ->first(); if(!empty($data['gallery'])){ if(isset($data['breadcrumb'][2]['url']) && !empty($data['breadcrumb'][2]['url'])){ $data['breadcrumb'][3]['url'] = ''; $data['breadcrumb'][3]['name'] = $data['gallery']->name; }else{ $data['breadcrumb'][2]['url'] = ''; $data['breadcrumb'][2]['name'] = $data['gallery']->name; } //min_sort $min_sort = $this->Galleries->find() ->contain(['GalleryCategories']) ->select(['min_sort' => $query->func()->min('Galleries.sort')]) ->where(['Galleries.company_id' => $company->id]) ->where(['Galleries.sort >' => $data['gallery']->sort]) ->where(['Galleries.display_flag' => 1]) ->where(['Galleries.delete_flag' => 0]); //ギャラリー複数化 if(!empty($data['newpage']->page_kind)){ $min_sort->where(['Galleries.gallery_kind' => $data['newpage']->page_kind]); }else{ $min_sort->where(['OR' => [['Galleries.gallery_kind' => ''], ['Galleries.gallery_kind IS NULL']]]); } $data['min_sort'] = $min_sort->first(); //max_sort $max_sort = $this->Galleries->find() ->contain(['GalleryCategories']) ->select(['max_sort' => $query->func()->max('Galleries.sort')]) ->where(['Galleries.company_id' => $company->id]) ->where(['Galleries.sort <' => $data['gallery']->sort]) ->where(['Galleries.display_flag' => 1]) ->where(['Galleries.delete_flag' => 0]); //ギャラリー複数化 if(!empty($data['newpage']->page_kind)){ $max_sort->where(['Galleries.gallery_kind' => $data['newpage']->page_kind]); }else{ $max_sort->where(['OR' => [['Galleries.gallery_kind' => ''], ['Galleries.gallery_kind IS NULL']]]); } $data['max_sort'] = $max_sort->first(); // if($tmp_reference_page->sort_flag == 1){ $prev_sort = $data['min_sort']->min_sort; $next_sort = $data['max_sort']->max_sort; }else{ $prev_sort = $data['max_sort']->max_sort; $next_sort = $data['min_sort']->min_sort; } //prev $prev_gallery = $this->Galleries->find() ->contain(['GalleryCategories']) ->where(['Galleries.company_id' => $company->id]) ->where(['Galleries.sort' => $prev_sort]) ->where(['Galleries.display_flag' => 1]) ->where(['Galleries.delete_flag' => 0]); //->first(); //ギャラリー複数化 if(!empty($data['newpage']->page_kind)){ $prev_gallery->where(['Galleries.gallery_kind' => $data['newpage']->page_kind]); }else{ $prev_gallery->where(['OR' => [['Galleries.gallery_kind' => ''], ['Galleries.gallery_kind IS NULL']]]); } $data['prev_gallery'] = $prev_gallery->first(); //next $next_gallery = $this->Galleries->find() ->contain(['GalleryCategories']) ->where(['Galleries.company_id' => $company->id]) ->where(['Galleries.sort' => $next_sort]) ->where(['Galleries.display_flag' => 1]) ->where(['Galleries.delete_flag' => 0]); //->first(); //ギャラリー複数化 if(!empty($data['newpage']->page_kind)){ $next_gallery->where(['Galleries.gallery_kind' => $data['newpage']->page_kind]); }else{ $next_gallery->where(['OR' => [['Galleries.gallery_kind' => ''], ['Galleries.gallery_kind IS NULL']]]); } $data['next_gallery'] = $next_gallery->first(); // if($page_mode == 'gallery_archive'){ if(!empty($data['prev_gallery'])){ $data['tmp_layer_prev'] = '/gallery_archive/detail/'.$data['prev_gallery']->id.'/'; }else{ $data['tmp_layer_prev'] = ''; } if(!empty($data['next_gallery'])){ $data['tmp_layer_next'] = '/gallery_archive/detail/'.$data['next_gallery']->id.'/'; }else{ $data['tmp_layer_next'] = ''; } } }else{ $data['breadcrumb'][2]['url'] = ''; $data['breadcrumb'][2]['name'] = 'NOT FOUND'; $data['gallery'] = new \stdClass; $data['gallery']->name = ''; $data['gallery']->image = ''; $data['gallery']->images = ''; } //タイトルの整形 $data['newpage']->title = $data['gallery']->name; // if($data['setting']->webp_flag == 2){ $this->viewBuilder()->layout('newframe_webp/gallery_detail'); }else{ $this->viewBuilder()->layout('newframe/gallery_detail'); } //全件・もしくはカテゴリ別 }else{ //全カテゴリのデータ取得 $query = $this->Galleries->find() ->contain(['GalleryCategories']) ->where(['Galleries.company_id' => $company->id]) //->where(['Galleries.gallery_category_id IN' => $category_id_array]) ->where(['Galleries.display_flag' => 1]) ->where(['Galleries.delete_flag' => 0]); //->order(['Galleries.sort' => 'ASC']); //->order(['GalleryCategories.sort' => 'ASC', 'Galleries.sort' => 'ASC']); //->order(['release_date' => 'DESC']) //昇順・降順 if($tmp_reference_page->sort_flag == 1){ //$query->order(['GalleryCategories.sort' => 'ASC', 'Galleries.sort' => 'DESC']); $query->order(['Galleries.sort' => 'DESC']); }else{ //$query->order(['GalleryCategories.sort' => 'ASC', 'Galleries.sort' => 'ASC']); $query->order(['Galleries.sort' => 'ASC']); } //ギャラリー複数化 if(!empty($data['newpage']->page_kind)){ $query->where(['Galleries.gallery_kind' => $data['newpage']->page_kind]); }else{ $query->where(['OR' => [['Galleries.gallery_kind' => ''], ['Galleries.gallery_kind IS NULL']]]); } //カテゴリの絞り込み if($fixed_slug == 'category'){ $tmp_gallery_categories_query = $this->GalleryCategories->find() ->select(['GalleryCategories.id', 'GalleryCategories.name', 'GalleryCategories.abbr']) ->where(['GalleryCategories.company_id' => $company->id]) ->where(['GalleryCategories.name' => urldecode($tag_category)]) ->where(['GalleryCategories.display_flag' => 1]) ->where(['GalleryCategories.delete_flag' => 0]); //->first(); //ギャラリー複数化 if(!empty($data['newpage']->page_kind)){ $tmp_gallery_categories_query->where(['GalleryCategories.gallery_kind' => $data['newpage']->page_kind]); }else{ $tmp_gallery_categories_query->where(['GalleryCategories.gallery_kind IS NULL']); } $tmp_gallery_categories = $tmp_gallery_categories_query->first(); $query->where(['Galleries.gallery_category_id' => $tmp_gallery_categories->id]); // $data['gallery_category'] = $tmp_gallery_categories; }else{ // if(isset($data['setting']->gallery_archive_title) && !empty($data['setting']->gallery_archive_title)){ $slug == $data['setting']->gallery_archive_title; $data['gallery_category'] = new \stdClass; $data['gallery_category']->name = $data['setting']->gallery_archive_title; //$data['gallery_category']->abbr = $data['setting']->gallery_archive_title; }else{ $slug == '全てを表示'; $data['gallery_category'] = new \stdClass; $data['gallery_category']->name = '全てを表示'; //$data['gallery_category']->abbr = '全てを表示'; } } //カテゴリ一覧 $gallery_category_query = $this->GalleryCategories->find() ->select(['GalleryCategories.name', 'GalleryCategories.abbr', 'GalleryCategories.gallery_kind']) ->where(['GalleryCategories.company_id' => $company->id]) ->where(['GalleryCategories.display_flag' => 1]) ->where(['GalleryCategories.delete_flag' => 0]) ->order(['GalleryCategories.sort' => 'ASC']); //->all(); //ギャラリー複数化 if(!empty($data['newpage']->page_kind)){ $gallery_category_query->where(['GalleryCategories.gallery_kind' => $data['newpage']->page_kind]); }else{ $gallery_category_query->where(['OR' => [['GalleryCategories.gallery_kind' => ''], ['GalleryCategories.gallery_kind IS NULL']]]); } $data['gallery_categories'] = $gallery_category_query->all(); // //$data['tmp_layer'] = $data['newpage']->slug; // if($data['setting']->webp_flag == 2){ $this->viewBuilder()->layout('newframe_webp/gallery_archive'); }else{ $this->viewBuilder()->layout('newframe/gallery_archive'); } } }elseif(is_numeric($slug)){ //カテゴリIDの取得 $tmp_block = $this->Blocks->find() //->select(['Pages.id', 'Pages.pagetype_id', 'Pages.parent_id', 'Pages.name', 'Pages.slug', 'Pages.title', 'Pages.sort', 'Pagetypes.id', 'Pagetypes.name']) //->contain(['BlockDetails']) ->where(['Blocks.id' => $slug]) ->where(['Blocks.company_id' => $company->id]) ->where(['Blocks.delete_flag' => 0]) ->first(); if(!empty($tmp_block)){ $data['gallery_category'] = new \stdClass; //$data['gallery_category']->name = $tmp_block->block_name; //$data['gallery_category']->abbr = $tmp_block->block_abbr; $data['gallery_category']->name = $tmp_block->headline; $data['gallery_category']->abbr = $tmp_block->subheadline; }else{ $data['gallery_category'] = new \stdClass; $data['gallery_category']->name = ''; $data['gallery_category']->abbr = ''; } $category_id_array = []; if($tmp_block->tmp_flag == 1){ if(!empty($tmp_block->text1)){ $category_id_array = explode(',', $tmp_block->text1); } }else{ if(!empty($tmp_block->block_details)){ $category_id_array = explode(',', $tmp_block->block_details[0]->content); } } //カテゴリに紐付くデータ取得 $query = $this->Galleries->find() ->contain(['GalleryCategories']) ->where(['Galleries.company_id' => $company->id]) ->where(['Galleries.gallery_category_id IN' => $category_id_array]) ->where(['Galleries.display_flag' => 1]) ->where(['Galleries.delete_flag' => 0]); //->order(['Galleries.sort' => 'ASC']); //->order(['GalleryCategories.sort' => 'ASC', 'Galleries.sort' => 'ASC']); if($tmp_reference_page->sort_flag == 1){ $query->order(['GalleryCategories.sort' => 'ASC', 'Galleries.sort' => 'DESC']); }else{ $query->order(['GalleryCategories.sort' => 'ASC', 'Galleries.sort' => 'ASC']); } //->order(['release_date' => 'DESC']) //カテゴリ一覧 //$data['gallery_categories'] = ''; // //$data['tmp_layer'] = '/'.$slug.'/gallery_archive/'; $data['tmp_layer'] = '/gallery_archive/'.$slug.'/'; // if($data['setting']->webp_flag == 2){ $this->viewBuilder()->layout('newframe_webp/gallery_archive'); }else{ $this->viewBuilder()->layout('newframe/gallery_archive'); } //全カテゴリ表示の場合 }elseif($slug == ''){ // if($data['setting']->webp_flag == 2){ $this->viewBuilder()->layout('newframe_webp/gallery_archive'); }else{ $this->viewBuilder()->layout('newframe/gallery_archive'); } //カテゴリ分け表示の場合 }else{ //カテゴリIDの取得 $data['gallery_category'] = $this->GalleryCategories->find() ->where(['GalleryCategories.company_id' => $company->id]) ->where(['GalleryCategories.name' => urldecode($slug)]) ->where(['GalleryCategories.display_flag' => 1]) //gallery_archiveの暫定対策 ->where(['GalleryCategories.gallery_kind IS NULL']) ->where(['GalleryCategories.delete_flag' => 0]) ->first(); if(empty($data['gallery_category'])){ return $this->redirect('/'); } //※※※暫定処理 $tag_category = urldecode($slug); //カテゴリに紐付くデータ取得 $query = $this->Galleries->find() ->contain(['GalleryCategories']) ->where(['Galleries.company_id' => $company->id]) ->where(['Galleries.gallery_category_id' => $data['gallery_category']->id]) ->where(['Galleries.display_flag' => 1]) ->where(['Galleries.delete_flag' => 0]) //gallery_archiveの暫定対策 ->where(['OR' => [['Galleries.gallery_kind' => ''], ['Galleries.gallery_kind IS NULL']]]) //->order(['Galleries.sort' => 'ASC']); ->order(['GalleryCategories.sort' => 'ASC', 'Galleries.sort' => 'ASC']); //->order(['release_date' => 'DESC']) //カテゴリ一覧 $data['gallery_categories'] = $this->GalleryCategories->find() ->select(['GalleryCategories.name']) ->where(['GalleryCategories.company_id' => $company->id]) ->where(['GalleryCategories.display_flag' => 1]) ->where(['GalleryCategories.delete_flag' => 0]) //gallery_archiveの暫定対策 ->where(['GalleryCategories.gallery_kind IS NULL']) ->order(['GalleryCategories.sort' => 'ASC']) ->all(); // //$data['tmp_layer'] = '/'.urldecode($slug).'/gallery_archive/'; $data['tmp_layer'] = '/gallery_archive/'.urldecode($slug).'/'; // if($data['setting']->webp_flag == 2){ $this->viewBuilder()->layout('newframe_webp/gallery_archive'); }else{ $this->viewBuilder()->layout('newframe/gallery_archive'); } } // if(!empty($tmp_reference_page->keywords)){ if(!empty($tag_category)){ $data['newpage']->keywords = urldecode($tag_category).','.$tmp_reference_page->keywords; }else{ $data['newpage']->keywords = $tmp_reference_page->keywords; } } if(!empty($tmp_reference_page->description)){ //if(!empty($tag_category)){ if(!empty($tag_category) && $fixed_slug != 'detail'){ $data['newpage']->description = urldecode($tag_category).'。'.$tmp_reference_page->description; }else{ $data['newpage']->description = $tmp_reference_page->description; } } if(!empty($tmp_reference_page->title)){ if($fixed_slug == 'detail' || $fixed_slug2 == 'detail'){ $data['newpage']->title = urldecode($data['gallery']->name).' | '.$tmp_reference_page->title; }elseif(!empty($tag_category)){ $data['newpage']->title = urldecode($tag_category).' | '.$tmp_reference_page->title; }else{ $data['newpage']->title = $tmp_reference_page->title; } } if(!empty($tmp_reference_page->h1_text)){ if($fixed_slug == 'detail' || $fixed_slug2 == 'detail'){ $data['newpage']->h1_text = urldecode($data['gallery']->name).' | '.$tmp_reference_page->h1_text; }elseif(!empty($tag_category)){ $data['newpage']->h1_text = urldecode($tag_category).' | '.$tmp_reference_page->h1_text; }else{ $data['newpage']->h1_text = $tmp_reference_page->h1_text; } } if(!empty($tmp_reference_page->name)){ $data['newpage']->name = $tmp_reference_page->name; } if(!empty($tmp_reference_page->common_footer_flag)){ $data['newpage']->common_footer_flag = $tmp_reference_page->common_footer_flag; } if(!empty($tmp_reference_page->image01)){ $data['newpage']->image01 = $tmp_reference_page->image01; } if(!empty($tmp_reference_page->other1)){ $data['newpage']->other1 = $tmp_reference_page->other1; } if(!empty($tmp_reference_page->other2)){ $data['newpage']->other2 = $tmp_reference_page->other2; } if(!empty($tmp_reference_page->other3)){ $data['newpage']->other3 = $tmp_reference_page->other3; } if(!empty($tmp_reference_page->other4)){ $data['newpage']->other4 = $tmp_reference_page->other4; } if(!empty($tmp_reference_page->header_headline)){ $data['newpage']->header_headline = $tmp_reference_page->header_headline; } if(!empty($tmp_reference_page->header_subheadline)){ $data['newpage']->header_subheadline = $tmp_reference_page->header_subheadline; } if(!empty($tmp_reference_page->header_text)){ $data['newpage']->header_text = $tmp_reference_page->header_text; } if(!empty($tmp_reference_page->header_align)){ $data['newpage']->header_align = $tmp_reference_page->header_align; } if(!empty($tmp_reference_page->header_align2)){ $data['newpage']->header_align2 = $tmp_reference_page->header_align2; } if(!empty($tmp_reference_page->footer_headline)){ $data['newpage']->footer_headline = $tmp_reference_page->footer_headline; } if(!empty($tmp_reference_page->footer_subheadline)){ $data['newpage']->footer_subheadline = $tmp_reference_page->footer_subheadline; } if(!empty($tmp_reference_page->footer_text)){ $data['newpage']->footer_text = $tmp_reference_page->footer_text; } if(!empty($tmp_reference_page->footer_align)){ $data['newpage']->footer_align = $tmp_reference_page->footer_align; } if(!empty($tmp_reference_page->footer_align2)){ $data['newpage']->footer_align2 = $tmp_reference_page->footer_align2; } if(!empty($tmp_reference_page->slug)){ $data['newpage']->tmp_slug = $tmp_reference_page->slug; } //暫定対策※※※ //if(empty($data['newpage']->slug) && $data['newpage']->pagetype_id != 8){ if(empty($data['newpage']->slug) && $page_mode == 'gallery_archive'){ $data['newpage']->slug = $tmp_reference_page->name; $data['breadcrumb'][2]['name'] = $tmp_reference_page->name; } //暫定対策※※※ //if(empty($data['breadcrumb'][2]['name']) && $data['newpage']->pagetype_id != 8){ if(empty($data['breadcrumb'][2]['name']) && $page_mode == 'gallery_archive'){ $data['breadcrumb'][2]['name'] = $tmp_reference_page->name; } // if(!empty($data['setting']->gallery_num)){ $limit = $data['setting']->gallery_num; }else{ $limit = 10; } if(!empty($data['others']['other2'])){ $limit = $data['others']['other2']; }else{ $limit = 10; } $query->limit($limit); //件数やページ数のセット if(!empty($page_num)){ $offset = ($limit * $page_num) - $limit; $query->offset($offset); } $count = $query->count(); // $total_result = $count; $result_start = $offset + 1; $result_end = $offset + $limit; if($result_end > $total_result){ $result_end = $total_result; } $this->set('total_result', $total_result); $this->set('result_start', $result_start); $this->set('result_end', $result_end); // $galleries = $query->all(); $data['galleries'] = $galleries; //ページネーション if(($count / $limit) > 0 && $count > 0){ $data['pagenation'] = $this->pagenation_data($page_num, $count, $limit); } //comparison_archive 関連データ //}elseif($fixed_slug == 'comparison_archive'){ //ビフォーアフターを枠対応にする //}elseif($fixed_slug == 'comparison_archive' || ($fixed_slug == 'category' && $slug == 'comparison_archive')){ }elseif(isset($data['newpage']) && ($data['newpage']->pagetype_id == 9 || $fixed_slug == 'comparison_archive' || ($fixed_slug == 'category' && $slug == 'comparison_archive'))){ //後から追加した機能、ギャラリーの枠として使用されているページのデータ取得 /*$tmp_reference_page_query = $this->Newpages->find() ->where(['Newpages.company_id' => $company->id]) ->where(['Newpages.pagetype_id' => 9]) ->where(['Newpages.delete_flag' => 0]); //->first();*/ /*if(!empty($data['page']->page_kind)){ $tmp_reference_page_query->where(['Pages.page_kind' => $data['page']->page_kind]); }else{ $tmp_reference_page_query->where(['OR' => [['Pages.page_kind' => ''], ['Pages.page_kind IS NULL']]]); }*/ //$tmp_reference_page = $tmp_reference_page_query->first(); //ページデータの取得 if($data['newpage']->pagetype_id == 9){ $comparison_mode = 'frame'; $tmp_comparison_slug = 'all'; }else{ $data['newpage'] = $this->Newpages->find() ->contain(['Tags', 'BlogCategories', 'BlogTags', 'NewsCategories']) ->where(['Newpages.company_id' => $company->id]) ->where(['Newpages.pagetype_id' => 9]) //->where(['Newpages.display_flag' => 1]) ->where(['Newpages.delete_flag' => 0]) ->first(); $comparison_mode = ''; } $this->set('comparison_mode', $comparison_mode); if(!empty($data['newpage'])){ $data['entries'] = json_decode($data['newpage']->entries, true); $data['headers'] = json_decode($data['newpage']->headers, true); $data['footers'] = json_decode($data['newpage']->footers, true); $data['others'] = json_decode($data['newpage']->others, true); $data['images'] = json_decode($data['newpage']->images, true); }else{ $this->setAction('routing'); return; /*$data['entries'] = ''; $data['headers'] = ''; $data['footers'] = ''; $data['others'] = ''; $data['images'] = '';*/ } $tmp_reference_page = $data['newpage']; //カテゴリ分け表示、一括表示の分岐 //一括表示の場合 if($slug == 'all' || ($tmp_comparison_slug == 'all' && empty($tag_category))){ //全カテゴリカテゴリのデータ取得 $query = $this->Comparisons->find() ->where(['Comparisons.company_id' => $company->id]) //->where(['Comparisons.comparison_category_id IN' => $category_id_array]) ->where(['Comparisons.display_flag' => 1]) ->where(['Comparisons.delete_flag' => 0]); //->order(['Comparisons.sort' => 'ASC']); if($tmp_reference_page->sort_flag == 1){ $query->order(['Comparisons.sort' => 'DESC']); }else{ $query->order(['Comparisons.sort' => 'ASC']); } //->order(['release_date' => 'DESC']) // if(isset($data['setting']->comparison_archive_title) && !empty($data['setting']->comparison_archive_title)){ $slug == $data['setting']->comparison_archive_title; $data['comparison_category'] = new \stdClass; $data['comparison_category']->name = $data['setting']->comparison_archive_title; //$data['comparison_category']->abbr = $data['setting']->comparison_archive_title; }else{ $slug == '全てを表示'; $data['comparison_category'] = new \stdClass; $data['comparison_category']->name = '全てを表示'; //$data['comparison_category']->abbr = '全てを表示'; } //カテゴリ一覧 $data['comparison_categories'] = $this->ComparisonCategories->find() ->select(['ComparisonCategories.name', 'ComparisonCategories.abbr']) ->where(['ComparisonCategories.company_id' => $company->id]) ->where(['ComparisonCategories.display_flag' => 1]) ->where(['ComparisonCategories.delete_flag' => 0]) ->order(['ComparisonCategories.sort' => 'ASC']) ->all(); // //$data['tmp_layer'] = '/'.$slug.'/comparison_archive/'; $data['tmp_layer'] = '/comparison_archive/'; if($data['setting']->webp_flag == 2){ $this->viewBuilder()->layout('newframe_webp/comparison_archive'); }else{ $this->viewBuilder()->layout('newframe/comparison_archive'); } }elseif(is_numeric($slug)){ //カテゴリIDの取得 $tmp_block = $this->Blocks->find() //※※※後で絞込精査 //->select(['Pages.id', 'Pages.pagetype_id', 'Pages.parent_id', 'Pages.name', 'Pages.slug', 'Pages.title', 'Pages.sort', 'Pagetypes.id', 'Pagetypes.name']) //->contain(['BlockDetails']) ->where(['Blocks.id' => $slug]) ->where(['Blocks.company_id' => $company->id]) ->where(['Blocks.delete_flag' => 0]) ->first(); if(!empty($tmp_block)){ $data['comparison_category'] = new \stdClass; //$data['comparison_category']->name = $tmp_block->block_name; //$data['comparison_category']->abbr = $tmp_block->block_abbr; $data['comparison_category']->name = $tmp_block->headline; $data['comparison_category']->abbr = $tmp_block->subheadline; }else{ $data['comparison_category'] = new \stdClass; $data['comparison_category']->name = ''; $data['comparison_category']->abbr = ''; } $category_id_array = []; if($tmp_block->tmp_flag == 1){ if(!empty($tmp_block->text1)){ $category_id_array = explode(',', $tmp_block->text1); } }else{ if(!empty($tmp_block->block_details)){ $category_id_array = explode(',', $tmp_block->block_details[0]->content); } } //カテゴリに紐付くデータ取得 $query = $this->Comparisons->find() ->where(['Comparisons.company_id' => $company->id]) ->where(['Comparisons.comparison_category_id IN' => $category_id_array]) ->where(['Comparisons.display_flag' => 1]) ->where(['Comparisons.delete_flag' => 0]); //->order(['Comparisons.sort' => 'ASC']); if($tmp_reference_page->sort_flag == 1){ $query->order(['Comparisons.sort' => 'DESC']); }else{ $query->order(['Comparisons.sort' => 'ASC']); } //->order(['release_date' => 'DESC']) //カテゴリ一覧 //$data['comparison_categories'] = ''; // //data['tmp_layer'] = '/'.$slug.'/comparison_archive/'; //$data['tmp_layer'] = '/comparison_archive/'.$slug.'/'; //$data['tmp_layer'] = '/comparison_archive/'.$tmp_block->headline.'/'; $data['tmp_layer'] = '/comparison_archive/'; //全カテゴリ表示の場合 }elseif($slug == ''){ //カテゴリ分け表示の場合 }else{ //カテゴリIDの取得 $data['comparison_category'] = $this->ComparisonCategories->find() ->where(['ComparisonCategories.company_id' => $company->id]) //->where(['ComparisonCategories.name' => urldecode($slug)]) ->where(['ComparisonCategories.name' => urldecode($tag_category)]) ->where(['ComparisonCategories.display_flag' => 1]) ->where(['ComparisonCategories.delete_flag' => 0]) ->first(); if(empty($data['comparison_category'])){ //return $this->redirect('/'); } //カテゴリに紐付くデータ取得 $query = $this->Comparisons->find() ->where(['Comparisons.company_id' => $company->id]) ->where(['Comparisons.comparison_category_id' => $data['comparison_category']->id]) ->where(['Comparisons.display_flag' => 1]) ->where(['Comparisons.delete_flag' => 0]); //->order(['Comparisons.sort' => 'ASC']); if($tmp_reference_page->sort_flag == 1){ $query->order(['Comparisons.sort' => 'DESC']); }else{ $query->order(['Comparisons.sort' => 'ASC']); } //->order(['release_date' => 'DESC']) //カテゴリ一覧 $data['comparison_categories'] = $this->ComparisonCategories->find() ->select(['ComparisonCategories.name']) ->where(['ComparisonCategories.company_id' => $company->id]) ->where(['ComparisonCategories.display_flag' => 1]) ->where(['ComparisonCategories.delete_flag' => 0]) ->order(['ComparisonCategories.sort' => 'ASC']) ->all(); // //$data['tmp_layer'] = '/'.urldecode($slug).'/comparison_archive/'; //$data['tmp_layer'] = '/comparison_archive/'.urldecode($slug).'/'; $data['tmp_layer'] = '/comparison_archive/'; if($data['setting']->webp_flag == 2){ $this->viewBuilder()->layout('newframe_webp/comparison_archive'); }else{ $this->viewBuilder()->layout('newframe/comparison_archive'); } } //後から追加した機能、ビフォーアフターの枠として使用されているページのデータ取得 //$data['reference_page'] = tmp_reference_page_query; /*$data['reference_page'] = $this->Pages->find() ->where(['Pages.company_id' => $company->id]) ->where(['Pages.pagetype_id' => 9]) ->where(['Pages.delete_flag' => 0]) ->first();*/ // if(!empty($tmp_reference_page->keywords)){ if(!empty($tag_category)){ $data['newpage']->keywords = urldecode($tag_category).','.$tmp_reference_page->keywords; }else{ $data['newpage']->keywords = $tmp_reference_page->keywords; } } if(!empty($tmp_reference_page->description)){ if(!empty($tag_category)){ $data['newpage']->description = urldecode($tag_category).'。'.$tmp_reference_page->description; }else{ $data['newpage']->description = $tmp_reference_page->description; } } if(!empty($tmp_reference_page->title)){ if($fixed_slug == 'detail' || $fixed_slug2 == 'detail'){ $data['newpage']->title = urldecode($data['gallery']->name).' | '.$tmp_reference_page->title; }elseif(!empty($tag_category)){ $data['newpage']->title = urldecode($tag_category).' | '.$tmp_reference_page->title; }else{ $data['newpage']->title = $tmp_reference_page->title; } } if(!empty($tmp_reference_page->h1_text)){ if($fixed_slug == 'detail' || $fixed_slug2 == 'detail'){ $data['newpage']->h1_text = urldecode($data['gallery']->name).' | '.$tmp_reference_page->h1_text; }elseif(!empty($tag_category)){ $data['newpage']->h1_text = urldecode($tag_category).' | '.$tmp_reference_page->h1_text; }else{ $data['newpage']->h1_text = $tmp_reference_page->h1_text; } } if(!empty($tmp_reference_page->name)){ $data['newpage']->name = $tmp_reference_page->name; } if(!empty($tmp_reference_page->common_footer_flag)){ $data['newpage']->common_footer_flag = $tmp_reference_page->common_footer_flag; } if(!empty($tmp_reference_page->image01)){ $data['newpage']->image01 = $tmp_reference_page->image01; } if(!empty($tmp_reference_page->other1)){ $data['newpage']->other1 = $tmp_reference_page->other1; } if(!empty($tmp_reference_page->other2)){ $data['newpage']->other2 = $tmp_reference_page->other2; } if(!empty($tmp_reference_page->other3)){ $data['newpage']->other3 = $tmp_reference_page->other3; } if(!empty($tmp_reference_page->other4)){ $data['newpage']->other4 = $tmp_reference_page->other4; } if(!empty($tmp_reference_page->header_headline)){ $data['newpage']->header_headline = $tmp_reference_page->header_headline; } if(!empty($tmp_reference_page->header_subheadline)){ $data['newpage']->header_subheadline = $tmp_reference_page->header_subheadline; } if(!empty($tmp_reference_page->header_text)){ $data['newpage']->header_text = $tmp_reference_page->header_text; } if(!empty($tmp_reference_page->header_align)){ $data['newpage']->header_align = $tmp_reference_page->header_align; } if(!empty($tmp_reference_page->header_align2)){ $data['newpage']->header_align2 = $tmp_reference_page->header_align2; } if(!empty($tmp_reference_page->footer_headline)){ $data['newpage']->footer_headline = $tmp_reference_page->footer_headline; } if(!empty($tmp_reference_page->footer_subheadline)){ $data['newpage']->footer_subheadline = $tmp_reference_page->footer_subheadline; } if(!empty($tmp_reference_page->footer_text)){ $data['newpage']->footer_text = $tmp_reference_page->footer_text; } if(!empty($tmp_reference_page->footer_align)){ $data['newpage']->footer_align = $tmp_reference_page->footer_align; } if(!empty($tmp_reference_page->footer_align2)){ $data['newpage']->footer_align2 = $tmp_reference_page->footer_align2; } if(!empty($tmp_reference_page->slug)){ $data['newpage']->tmp_slug = $tmp_reference_page->slug; } //暫定対策※※※ //if(empty($data['newpage']->slug) && $data['newpage']->pagetype_id != 8){ if(empty($data['newpage']->slug) && $fixed_slug == 'comparison_archive'){ $data['newpage']->slug = $tmp_reference_page->name; $data['breadcrumb'][2]['name'] = $tmp_reference_page->name; } //暫定対策※※※ //if(empty($data['newpage']->slug) && $data['newpage']->pagetype_id != 8){ if($fixed_slug == 'category'){ $data['newpage']->slug = $tmp_reference_page->name; $data['breadcrumb'][2]['name'] = $tmp_reference_page->name; $data['breadcrumb'][2]['url'] = '/comparison_archive/all/'; $data['breadcrumb'][3]['name'] = urldecode($tag_category); } //暫定対策※※※ //if(empty($data['breadcrumb'][2]['name']) && $data['newpage']->pagetype_id != 8){ if(empty($data['breadcrumb'][2]['name']) && $fixed_slug == 'comparison_archive'){ $data['breadcrumb'][2]['name'] = $tmp_reference_page->name; } // /*if(!empty($data['setting']->comparison_num)){ $limit = $data['setting']->comparison_num; }elseif(!empty($data['page']->other2)){ $limit = $data['page']->other2; }else{ $limit = 10; }*/ if(!empty($data['others']['other2'])){ $limit = $data['others']['other2']; }else{ $limit = 10; } $query->limit($limit); //件数やページ数のセット if(!empty($page_num)){ $offset = ($limit * $page_num) - $limit; $query->offset($offset); } $count = $query->count(); // $total_result = $count; $result_start = $offset + 1; $result_end = $offset + $limit; if($result_end > $total_result){ $result_end = $total_result; } $this->set('total_result', $total_result); $this->set('result_start', $result_start); $this->set('result_end', $result_end); // $comparisons = $query->all(); $data['comparisons'] = $comparisons; //ページネーション if(($count / $limit) > 0 && $count > 0){ $data['pagenation'] = $this->pagenation_data($page_num, $count, $limit); } //※※※ if($comparison_mode == 'frame'){ unset($data['tmp_layer']); } //リクルート一覧の場合 }elseif(isset($data['newpage']) && $data['newpage']->pagetype_id == 10){ //詳細ページの場合 if($fixed_slug == 'detail' || $fixed_slug2 == 'detail'){ $data['recruit'] = $this->Recruits->find() ->where(['Recruits.id' => $tag_category]) ->where(['Recruits.company_id' => $company->id]) ->where(['Recruits.display_flag' => 1]) ->where(['Recruits.delete_flag' => 0]) ->first(); if(empty($data['recruit'])){ if($data['setting']->webp_flag == 2){ $this->viewBuilder()->layout('newframe_webp/404'); }else{ $this->viewBuilder()->layout('newframe/404'); } }else{ //$data['breadcrumb'][2]['name'] = '詳細'; //$data['breadcrumb'][2]['url'] = ''; $tmp_breadcrumb = []; $tmp_breadcrumb['name'] = '詳細'; $tmp_breadcrumb['url'] = ''; $data['breadcrumb'][] = $tmp_breadcrumb; // $data['newpage']->keywords = $data['recruit']->job_type; $data['newpage']->description = $data['recruit']->content; $data['newpage']->title = $data['recruit']->title.' | '.$data['newpage']->title; $data['newpage']->h1_text = $data['recruit']->title; // if($data['recruit']->insert_mode == 1){ if($data['setting']->webp_flag == 2){ $this->viewBuilder()->layout('newframe_webp/recruit_eg_detail'); }else{ $this->viewBuilder()->layout('newframe/recruit_eg_detail'); } }else{ if($data['setting']->webp_flag == 2){ $this->viewBuilder()->layout('newframe_webp/recruit_detail'); }else{ $this->viewBuilder()->layout('newframe/recruit_detail'); } } } //一覧の場合 }else{ //紐付くデータの取得 $query = $this->Recruits->find() ->where(['Recruits.company_id' => $company->id]) ->where(['Recruits.display_flag' => 1]) ->where(['Recruits.delete_flag' => 0]); //->order(['Recruits.sort' => 'ASC']); // if($data['newpage']->sort_flag){ $query->order(['Recruits.sort' => 'DESC']); }else{ $query->order(['Recruits.sort' => 'ASC']); } // if(!empty($data['others']['other2'])){ $limit = $data['others']['other2']; }else{ $limit = 10; } //カテゴリの絞り込み if($fixed_slug == 'category'){ $tmp_recruit_categories_query = $this->RecruitCategories->find() ->select(['RecruitCategories.id']) ->where(['RecruitCategories.company_id' => $company->id]) ->where(['RecruitCategories.name' => urldecode($tag_category)]) ->where(['RecruitCategories.display_flag' => 1]) ->where(['RecruitCategories.delete_flag' => 0]); //->first(); //ギャラリー複数化 /*if(!empty($data['page']->page_kind)){ $tmp_recruit_categories_query->where(['RecruitCategories.gallery_kind' => $data['page']->page_kind]); }else{ $tmp_recruit_categories_query->where(['RecruitCategories.gallery_kind IS NULL']); }*/ $tmp_recruit_categories = $tmp_recruit_categories_query->first(); $query->where(['Recruits.recruit_category_id' => $tmp_recruit_categories->id]); } // $query->limit($limit); //件数やページ数のセット if(!empty($page_num)){ $offset = ($limit * $page_num) - $limit; $query->offset($offset); } $count = $query->count(); // $total_result = $count; $result_start = $offset + 1; $result_end = $offset + $limit; if($result_end > $total_result){ $result_end = $total_result; } $this->set('total_result', $total_result); $this->set('result_start', $result_start); $this->set('result_end', $result_end); // $recruits = $query->all(); $data['recruits'] = $recruits; //カテゴリ一覧 $data['recruit_categories'] = $this->RecruitCategories->find() ->select(['RecruitCategories.name', 'RecruitCategories.abbr']) ->where(['RecruitCategories.company_id' => $company->id]) ->where(['RecruitCategories.display_flag' => 1]) ->where(['RecruitCategories.delete_flag' => 0]) ->order(['RecruitCategories.sort' => 'ASC']) ->all(); //ページネーション if(($count / $limit) > 0 && $count > 0){ $data['pagenation'] = $this->pagenation_data($page_num, $count, $limit); } // if($data['setting']->webp_flag == 2){ $this->viewBuilder()->layout('newframe_webp/recruit_archive'); }else{ $this->viewBuilder()->layout('newframe/recruit_archive'); } } //Youtubelistの場合 }elseif(isset($data['newpage']) && $data['newpage']->pagetype_id == 13){ //GoogleAPIライブラリを読み込む //require_once ('/var/www/html/application/lib/google-api-php-client-2.2.0/vendor/autoload.php'); //API関連の取得 $youtube_Setting = $this->Youtube->find() ->where(['Youtube.company_id' => $company->id]) ->first(); // $chanel_id = $youtube_Setting['chanel_id']; $api_key = $youtube_Setting['api_key']; if(!empty($data['others']['other2'])){ $result_num = $data['others']['other2']; }else{ $result_num = 10; } if(isset($_GET['ptk']) && !empty($_GET['ptk'])){ $page_token = $_GET['ptk']; }else{ $page_token = ''; } $category = ''; $data['youtubes'] = $this->searchVideos($chanel_id, $api_key, $result_num, $page_token, $tag_category); // if($data['setting']->webp_flag == 2){ $this->viewBuilder()->layout('newframe_webp/youtube_archive'); }else{ $this->viewBuilder()->layout('newframe/youtube_archive'); } //口コミの場合 }elseif(isset($data['newpage']) && $data['newpage']->pagetype_id == 14){ // /*$infobiz = $this->Infobizs->find() ->where(['Infobizs.company_id' => $company->id]) ->first();*/ // $data['comments'] = []; $data['comment_shop'] = []; $data['new_review_uri'] = ''; if(is_numeric($_GET['location_id'])){ $select_location_id = $_GET['location_id']; }else{ $select_location_id = ''; } if($_SERVER['REMOTE_ADDR'] == '202.12.244.62'){ var_dump($select_location_id); } $data['select_location_id'] = $select_location_id; // if(!empty($company->infobiz_account) && !empty($company->infobiz_password)){ // $username = $company->infobiz_account; $password = $company->infobiz_password; $api_key = 'lm6WSidQFb6UD5DsAUGd522Ec1tNPpBOqR8l0Lk0'; // $auth_login_json = $this->authLogin($api_key, $username, $password); $auth_login_datas = json_decode($auth_login_json, true); $token = $auth_login_datas['result']['token']; $location_id = $auth_login_datas['result']['user']['locations'][0]['id']; // //$basic_info_json = $this->getBasicInfo($api_key, $token, $location_id); if(!empty($select_location_id)){ $basic_info_json = $this->getBasicInfo($api_key, $token, $select_location_id); }else{ $basic_info_json = $this->getBasicInfo($api_key, $token, $location_id); } $basic_info_datas = json_decode($basic_info_json, true); $data['new_review_uri'] = $basic_info_datas['result']['basic_information']['new_review_uri']; // $postdata_json = $this->getReview($api_key, $token); $postdata_datas = json_decode($postdata_json, true); // if(isset($postdata_datas['result']['data']) && !empty($postdata_datas['result']['data'])){ foreach($postdata_datas['result']['data'] as $comment){ //if(empty($select_location_id) || (!empty($select_location_id) && $select_location_id == $comment['location']['id'])){ if($comment['status'] < 6){ if(empty($select_location_id) || (!empty($select_location_id) && $select_location_id == $comment['location']['id'])){ $tmp_comments = []; $tmp_comments['gmb_reviewer_profile_photo_url'] = $comment['gmb_reviewer_profile_photo_url']; $tmp_comments['gmb_reviewer_display_name'] = $comment['gmb_reviewer_display_name']; $tmp_comments['gmb_star_rating'] = $comment['gmb_star_rating']; $tmp_comments['post_datetime'] = $comment['post_datetime']; $tmp_comments['review_comment'] = $comment['review_comment']; $tmp_comments['status'] = $comment['status']; if($data['others']['reply'] == 1){ $tmp_comments['reply'] = $comment['reply']; }else{ $tmp_comments['reply'] = ''; } if($data['others']['display_value'] <= $comment['rating'] && in_array($comment['location']['id'], $data['others']['location_id'])){ //if($data['others']['display_value'] <= $comment['rating'] && in_array($data['others']['location_id'], $comment['location']['id'])){ $data['comments'][] = $tmp_comments; /*if($comments_count == $comments_num){ break; }else{ $comments_count++; }*/ } } } //コメントが表示対象であってもなくても店舗はセット if(isset($data['others']['location_id']) && !empty($data['others']['location_id'])){ if(in_array($comment['location']['id'], $data['others']['location_id'])){ $data['comment_shop'][$comment['location']['id']] = $comment['location']['name']; } }else{ $data['comment_shop'][$comment['location']['id']] = $comment['location']['name']; } } } } // if($data['setting']->webp_flag == 2){ $this->viewBuilder()->layout('newframe_webp/comments_archive'); }else{ $this->viewBuilder()->layout('newframe/comments_archive'); } }elseif($slug_plus == '/sitemap/'){ $data['newpage'] = new \stdClass; $data['newpage']->id = 9999999999; $data['newpage']->parent_id = '0'; $data['newpage']->pagetype_id = ''; $data['newpage']->keywords = $data['setting']->sitemap_keywords; $data['newpage']->description = $data['setting']->sitemap_description; $data['newpage']->title = $data['setting']->sitemap_title; $data['newpage']->h1_text = $data['setting']->sitemap_h1; $data['newpage']->name = $data['setting']->sitemap_title; $data['newpage']->slug = 'sitemap'; $data['newpage']->basic_account = ''; $data['newpage']->basic_password = ''; $data['headers']['h_d_flag'] = 1; $data['headers']['h_d_logo_flag'] = 1; $data['headers']['h_d_navi_flag'] = 1; $data['headers']['h_d_mv_flag'] = 1; $data['footers']['f_d_flag'] = 1; $data['footers']['f_d_logo_flag'] = 1; $data['footers']['f_d_navi_flag'] = 1; $data['footers']['f_d_sns_flag'] = 1; $data['breadcrumb'][1]['url'] = '/'; $data['breadcrumb'][1]['name'] = $breadcrumb_text; $data['breadcrumb'][2]['url'] = '/sitemap/'; if(!empty($data['setting']->sitemap_link)){ $data['breadcrumb'][2]['name'] = $data['setting']->sitemap_link; }else{ $data['breadcrumb'][2]['name'] = 'サイトマップ'; } // $data['sitemap'] = $this->newsitemap_data($company->id); // if($data['setting']->webp_flag == 2){ $this->viewBuilder()->layout('newframe_webp/single'); }else{ $this->viewBuilder()->layout('newframe/single'); } }elseif($slug_plus == '/cookie_policy/'){ $data['newpage'] = new \stdClass; $data['newpage']->id = 9999999999; $data['newpage']->parent_id = '0'; $data['newpage']->pagetype_id = ''; $data['newpage']->keywords = 'クッキーポリシー'; $data['newpage']->description = 'クッキーポリシー'; $data['newpage']->title = 'クッキーポリシー'; $data['newpage']->h1_text = 'クッキーポリシー'; $data['newpage']->name = 'クッキーポリシー'; $data['newpage']->slug = 'cookie_policy'; $data['newpage']->basic_account = ''; $data['newpage']->basic_password = ''; $data['headers']['h_d_flag'] = 1; $data['headers']['h_d_logo_flag'] = 1; $data['headers']['h_d_navi_flag'] = 1; $data['headers']['h_d_mv_flag'] = 1; $data['footers']['f_d_flag'] = 1; $data['footers']['f_d_logo_flag'] = 1; $data['footers']['f_d_navi_flag'] = 1; $data['footers']['f_d_sns_flag'] = 1; $data['breadcrumb'][1]['url'] = '/'; $data['breadcrumb'][1]['name'] = $breadcrumb_text; $data['breadcrumb'][2]['url'] = '/cookie_policy/'; $data['breadcrumb'][2]['name'] = 'クッキーポリシー'; // //$data['sitemap'] = $this->newsitemap_data($company->id); $data['cookie_policy'] = $this->newsitemap_data($company->id); // /*if($data['setting']->webp_flag == 2){ $this->viewBuilder()->layout('newframe_webp/single'); }else{ $this->viewBuilder()->layout('newframe/single'); }*/ $this->viewBuilder()->layout('newframe/cookie_policy'); }elseif($slug_plus == '/page/'){ $data['newpage'] = new \stdClass; $data['newpage']->id = ''; $data['newpage']->parent_id = '0'; $data['newpage']->pagetype_id = ''; $data['newpage']->name = 'タグ『#'.urldecode($tag_category).'』のページ一覧'; $data['newpage']->keywords = 'タグ『#'.urldecode($tag_category).'』のページ一覧'; $data['newpage']->description = 'タグ『#'.urldecode($tag_category).'』のページ一覧'; $data['newpage']->title = 'タグ『#'.urldecode($tag_category).'』のページ一覧'; if(isset($data['tmp_tag']->h1_text) && !empty($data['tmp_tag']->h1_text)){ $data['newpage']->h1_text = $data['tmp_tag']->h1_text; }else{ $data['newpage']->h1_text = 'タグ『#'.urldecode($tag_category).'』のページ一覧'; } $data['newpage']->name = 'タグ『#'.urldecode($tag_category).'』のページ一覧'; $data['newpage']->slug = 'page'; $data['newpage']->basic_account = ''; $data['newpage']->basic_password = ''; $data['headers']['h_d_flag'] = 1; $data['headers']['h_d_logo_flag'] = 1; $data['headers']['h_d_navi_flag'] = 1; $data['headers']['h_d_mv_flag'] = 1; $data['footers']['f_d_flag'] = 1; $data['footers']['f_d_logo_flag'] = 1; $data['footers']['f_d_navi_flag'] = 1; $data['footers']['f_d_sns_flag'] = 1; $data['breadcrumb'][1]['url'] = '/'; $data['breadcrumb'][1]['name'] = $breadcrumb_text; $data['breadcrumb'][2]['url'] = '/page/tag/'.urldecode($tag_category).'/'; $data['breadcrumb'][2]['name'] = '#'.urldecode($tag_category); // if($data['setting']->webp_flag == 2){ $this->viewBuilder()->layout('newframe_webp/category_tag'); }else{ $this->viewBuilder()->layout('newframe/category_tag'); } }elseif(isset($data['newpage']) && $data['newpage']->pagetype_id == 15){ $query = $this->Newpages->find() ->select(['Newpages.id', 'Newpages.slug', 'Newpages.name', 'Newpages.title', 'Newpages.images', 'Newpages.excerpt', 'Newpages.ameblo_content', 'Newpages.company_id', 'Newpages.pagetype_id', 'Newpages.release_date', 'Newpages.description', 'Newpages.display_flag', 'Newpages.delete_flag']) ->where(['Newpages.company_id' => $company->id]) //->where(['Pages.parent_id' => $data['page']->id]) //->where(['Newpages.pagetype_id IN' => [1, 2, 3, 4, 5, 6]]) //->where(['Newpages.pagetype_id IN' => [1, 2, 3, 4, 6]]) //->where(['Newpages.pagetype_id IN' => [4, 5, 6]]) ->where(['Newpages.pagetype_id' => 4]) ->where(['Newpages.parent_id' => 0]) ->where(['Newpages.ai_flag' => 4]) ->where(['Newpages.display_flag' => 1]) ->where(['Newpages.delete_flag' => 0]) // ->where(['OR' => [['Newpages.release_date IS NULL'], ['Newpages.release_date <=' => date('Y-m-d H:i:s')]]]) //スロークエリ改善 //->order(['release_date' => 'DESC']); ->order(['Newpages.id' => 'DESC']); if(!empty($data['others']['other2'])){ $limit = $data['others']['other2']; }else{ $limit = 10; } $query->limit($limit); if(!empty($page_num)){ $offset = ($limit * $page_num) - $limit; $query->offset($offset); } $articles = $query->all(); $count = $query->count(); if(($count / $limit) > 0 && $count > 0){ $data['pagenation'] = $this->pagenation_data($page_num, $count, $limit); } $data['articles'] = $articles; if($data['setting']->webp_flag == 2){ $this->viewBuilder()->layout('newframe_webp/f_archive'); }else{ $this->viewBuilder()->layout('newframe/f_archive'); } } //サブナビゲーション $navigation_page_id = ''; if(isset($data['parent_page'])){ $tmp_navigation_id = $data['parent_page']->navigation_id; }else{ if(isset($data['newpage'])){ $tmp_navigation_id = $data['newpage']->navigation_id; } } //if(!empty($data['newpage']->navigation_id)){ if(!empty($tmp_navigation_id)){ $navigation_data = $this->Navigations->find() //->where(['Navigations.id' => $data['newpage']->navigation_id]) ->where(['Navigations.id' => $tmp_navigation_id]) ->where(['Navigations.company_id' => $company->id]) ->where(['Navigations.delete_flag' => 0]) ->first(); if(!empty($navigation_data)){ $data['setting']->loading_image = $navigation_data->loading_image; $data['setting']->common_tel = $navigation_data->common_tel; $data['setting']->common_address = $navigation_data->common_address; $data['setting']->common_hour = $navigation_data->common_hour; $data['setting']->logo_image = $navigation_data->logo_image; $data['setting']->header_logo_link = $navigation_data->header_logo_link; $data['setting']->translate_flag = $navigation_data->translate_flag; $data['setting']->h_tel_flag = $navigation_data->h_tel_flag; $data['setting']->h_address_flag = $navigation_data->h_address_flag; $data['setting']->h_hour_flag = $navigation_data->h_hour_flag; $data['setting']->h_button_flag = $navigation_data->h_button_flag; $data['setting']->header_link_type = $navigation_data->header_link_type; $data['setting']->header_link = $navigation_data->header_link; $data['setting']->header_text = $navigation_data->header_text; $data['setting']->header_link_target = $navigation_data->header_link_target; $data['setting']->text_align_flag = $navigation_data->text_align_flag; $data['setting']->footer_image = $navigation_data->footer_image; $data['setting']->footer_logo_link = $navigation_data->footer_logo_link; $data['setting']->footer_flag = $navigation_data->footer_flag; $data['setting']->f_tel_flag = $navigation_data->f_tel_flag; $data['setting']->f_hour_flag = $navigation_data->f_hour_flag; $data['setting']->f_button_flag = $navigation_data->f_button_flag; $data['setting']->footer_link_type = $navigation_data->footer_link_type; $data['setting']->footer_link = $navigation_data->footer_link; $data['setting']->footer_text = $navigation_data->footer_text; $data['setting']->footer_link_target = $navigation_data->footer_link_target; $data['setting']->mystyle_css = $navigation_data->mystyle_css; $data['setting']->css_font = $navigation_data->css_font; // $navigation_page_id = $navigation_data->page_id; $data['navigation_id'] = $tmp_navigation_id; $data['navigation_page_id'] = $navigation_page_id; } } //ナビデータ if(!empty($navigation_page_id)){ $data['navi'] = $this->new_sub_navi_data($company->id, $navigation_page_id); }else{ $data['navi'] = $this->new_navi_data($company->id); } // if(isset($data['newpage']) && isset($data['newpage']->common_footer_flag) && $data['newpage']->common_footer_flag == 1){ $data['common_footer'] = $data['setting']->footer_html; preg_match_all('/{newblock_id:(.*?)}/s', $data['common_footer'], $newblock_ids); // if($fixed_slug == 'form_conf' || $fixed_slug == 'form_send'){ foreach($newblock_ids[1] as $key=>$newblock_id){ $html = ''; if($newblock_id == $form_block_id){ $html = $this->blockToHtml($company->id, $company->subdomain, $newblock_id, $slug_plus, $fixed_slug, '', $data['setting']->logo_image, $contact_gallery_id, $company->cms_version, $contact_recruit_id, '', ''); } $data['common_footer'] = str_replace($newblock_ids[0][$key], $html, $data['common_footer']); } }else{ foreach($newblock_ids[1] as $key=>$newblock_id){ $html = ''; $html = $this->blockToHtml($company->id, $company->subdomain, $newblock_id, $slug_plus, $fixed_slug, '', $data['setting']->logo_image, $contact_gallery_id, $company->cms_version, $contact_recruit_id, '', ''); $data['common_footer'] = str_replace($newblock_ids[0][$key], $html, $data['common_footer']); } } } //※※※ if(!isset($data['tmp_layer'])){ $data['tmp_layer'] = $slug_plus; } if(!empty($archive_year) && !empty($archive_month)){ $data['tmp_layer'] = $slug_plus.'archive/'.$archive_year.'/'.$archive_month.'/'; } if(isset($tag_category)){ $data['tag_category'] = urldecode($tag_category); }else{ $data['tag_category'] = ''; } $data['archive_year'] = $archive_year; $data['archive_month'] = $archive_month; //Basic認証の設定 /*if(OP_MODE == 'subdomain'){ $this->basic_authenticate('iplambda', 'iplambda'); }elseif(!empty($data['page']) && !empty($data['page']->basic_account) && !empty($data['page']->basic_password)){ $this->basic_authenticate($data['page']->basic_account, $data['page']->basic_password); }elseif(!empty($data['setting']->basic_account) && !empty($data['setting']->basic_password)){ $this->basic_authenticate($data['setting']->basic_account, $data['setting']->basic_password); }*/ if(!empty($data['newpage']) && !empty($data['newpage']->basic_account) && !empty($data['newpage']->basic_password)){ $this->basic_authenticate($data['newpage']->basic_account, $data['newpage']->basic_password); // }elseif(isset($data['parent_page']) && !empty($data['parent_page']->basic_account) && !empty($data['parent_page']->basic_password)){ $this->basic_authenticate($data['parent_page']->basic_account, $data['parent_page']->basic_password); }elseif(!empty($data['setting']->basic_account) && !empty($data['setting']->basic_password)){ $this->basic_authenticate($data['setting']->basic_account, $data['setting']->basic_password); } //text-align $data['text_align'] = ''; if($data['setting']->text_align_flag == 1){ $data['text_align'] = ' align-center'; }elseif($data['setting']->text_align_flag == 2){ $data['text_align'] = ' align-right'; } //ログイン状態の確認 if($this->Cookie->check('ipp_lambda_admin_base')){ $cookie_data = $this->Cookie->read('ipp_lambda_admin_base'); //if($cookie_data['company_domain'] == $_SERVER['HTTP_HOST'] || $cookie_data['company_subdomain'].'.onerank-cms.com' == $_SERVER['HTTP_HOST']){ if($cookie_data['company_domain'] == $domain_name || $cookie_data['company_subdomain'].'.onerank-cms.com' == $domain_name || $cookie_data['company_subdomain'].'.onerank-cms-2.com' == $domain_name || $cookie_data['company_subdomain'].'.onerank-cms-3.com' == $domain_name || $cookie_data['company_subdomain'].'.onerank-hybrid-dev.com' == $domain_name || $cookie_data['company_subdomain'].'.onerank-hybrid-dev2.com' == $domain_name || $cookie_data['company_subdomain'].'.onerank-hybrid-dev3.com' == $domain_name){ $data['login_state'] = 'login'; $data['user_name'] = $cookie_data['user_name']; }else{ $data['login_state'] = 'logout'; } }else{ $data['login_state'] = 'logout'; } //タイトルの整形 if(!empty($data['setting']->seo_title)){ if($data['newpage']->pagetype_id == 6){ if($data['parent_others']['other4'] == 1){ $data['newpage']->title = $data['newpage']->title.' | '.$data['parent_page']->title.' | '.$data['setting']->seo_title; }else{ $data['newpage']->title = $data['newpage']->title.' | '.$data['setting']->seo_title; } }elseif($data['newpage']->pagetype_id == 1){ $data['newpage']->title = $data['setting']->seo_title.' | '.$data['newpage']->title; }else{ if($data['newpage']->seo_title_flag == 1){ $data['newpage']->title = $data['newpage']->title.' | '.$data['setting']->seo_title; }else{ //$data['newpage']->title = $data['newpage']->title.' | '.$data['setting']->seo_title; } } } //暫定対応 $data['iframe_mode'] = ''; $data['page_num'] = $page_num; $data['fixed_slug'] = $fixed_slug; //webp $ua = $_SERVER['HTTP_USER_AGENT']; if(strstr($ua, 'Trident') || strstr($ua, 'MSIE') || strstr($ua, 'KAIOS')){ }else{ if($data['setting']->webp_flag == 2){ $data['html'] = $this->Webp->fileCheck($data['html'], $company->subdomain, $data['newpage']->page_kind); /*if($company->id == '11705'){ $data['html'] = str_replace('?', '', $data['html']); }*/ if(isset($data['common_footer']) && !empty($data['common_footer'])){ $data['common_footer'] = $this->Webp->fileCheck($data['common_footer'], $company->subdomain, $data['newpage']->page_kind); } } } //リッチリザルト if($data['setting']->richresult_flag == 1){ // if(!empty($data['newpage']->richresult_id)){ $richresult_id = $data['newpage']->richresult_id; }else{ $richresult_id = $data['setting']->richresult_id; } $data['richresult'] = $this->Richresults->find() ->where(['Richresults.id' => $richresult_id]) ->where(['Richresults.company_id' => $company->id]) ->where(['Richresults.delete_flag' => 0]) ->first(); //HTMLデータによくある質問パーツを含む場合 if(strpos($data['html'], 'block_question') !== false){ // $data['questions'] = $this->Questions->find() ->where(['Questions.company_id' => $company->id]) ->where(['Questions.display_flag' => 1]) ->where(['Questions.delete_flag' => 0]) ->order(['Questions.sort' => 'ASC']) ->all(); } }else{ $data['richresult'] = ''; $data['questions'] = ''; } //popup_banners //0:共通設定 //1:表示しない $data['popup_banners'] = []; $data['popup_banners'][0]['id'] = '';//離脱防止バナー $data['popup_banners'][0]['data'] = ''; $data['popup_banners'][0]['text_style'] = ''; $data['popup_banners'][0]['button_style'] = ''; $data['popup_banners'][1]['id'] = '';//スクロールバナー $data['popup_banners'][1]['volume'] = ''; $data['popup_banners'][1]['data'] = ''; $data['popup_banners'][1]['text_style'] = ''; $data['popup_banners'][1]['button_style'] = ''; $data['popup_banners'][2]['id'] = '';//滞在時間バナー $data['popup_banners'][2]['min'] = ''; $data['popup_banners'][2]['data'] = ''; $data['popup_banners'][2]['text_style'] = ''; $data['popup_banners'][2]['button_style'] = ''; //共通設定があるか確認 if(isset($data['setting']->pb_json) && !empty($data['setting']->pb_json)){ //共通設定のセット $popup_banner = json_decode($data['setting']->pb_json, true); $data['popup_banners'][0]['id'] = $popup_banner['pb_flag']; $data['popup_banners'][1]['id'] = $popup_banner['pb_s_flag']; $data['popup_banners'][1]['volume'] = $popup_banner['pb_s_volume']; $data['popup_banners'][2]['id'] = $popup_banner['pb_t_flag']; $data['popup_banners'][2]['min'] = $popup_banner['pb_t_min']; //記事の場合、親の設定を先にセット if($data['newpage']->pagetype_id == 6){ if(!empty($data['parent_page']->pb_json)){ $popup_banner = json_decode($data['parent_page']->pb_json, true); // if($popup_banner['pb_flag'] == 0){ }elseif($popup_banner['pb_flag'] == 1){ $data['popup_banners'][0]['id'] = ''; }else{ $data['popup_banners'][0]['id'] = $popup_banner['pb_flag']; } // if($popup_banner['pb_s_flag'] == 0){ }elseif($popup_banner['pb_s_flag'] == 1){ $data['popup_banners'][1]['id'] = ''; $data['popup_banners'][1]['volume'] = ''; }else{ $data['popup_banners'][1]['id'] = $popup_banner['pb_s_flag']; $data['popup_banners'][1]['volume'] = $popup_banner['pb_s_volume']; } // if($popup_banner['pb_t_flag'] == 0){ }elseif($popup_banner['pb_t_flag'] == 1){ $data['popup_banners'][2]['id'] = ''; $data['popup_banners'][2]['min'] = ''; }else{ $data['popup_banners'][2]['id'] = $popup_banner['pb_t_flag']; $data['popup_banners'][2]['min'] = $popup_banner['pb_t_min']; } } } //固定ページ・記事ページ個別で設定されている場合、上書き if(!empty($data['newpage']->pb_json)){ $popup_banner = json_decode($data['newpage']->pb_json, true); // if($popup_banner['pb_flag'] == 0){ }elseif($popup_banner['pb_flag'] == 1){ $data['popup_banners'][0]['id'] = ''; }else{ $data['popup_banners'][0]['id'] = $popup_banner['pb_flag']; } // if($popup_banner['pb_s_flag'] == 0){ }elseif($popup_banner['pb_s_flag'] == 1){ $data['popup_banners'][1]['id'] = ''; $data['popup_banners'][1]['volume'] = ''; }else{ $data['popup_banners'][1]['id'] = $popup_banner['pb_s_flag']; $data['popup_banners'][1]['volume'] = $popup_banner['pb_s_volume']; } // if($popup_banner['pb_t_flag'] == 0){ }elseif($popup_banner['pb_t_flag'] == 1){ $data['popup_banners'][2]['id'] = ''; $data['popup_banners'][2]['min'] = ''; }else{ $data['popup_banners'][2]['id'] = $popup_banner['pb_t_flag']; $data['popup_banners'][2]['min'] = $popup_banner['pb_t_min']; } } } // for($i=0;$i<=2;$i++){ if(!empty($data['popup_banners'][$i]['id'])){ $text_style = ''; $button_style = ''; $data['popup_banners'][$i]['data'] = $this->PopupBanners->find() ->where(['PopupBanners.id' => $data['popup_banners'][$i]['id']]) ->where(['PopupBanners.company_id' => $company->id]) ->where(['PopupBanners.delete_flag' => 0]) ->first(); // if(!empty($data['popup_banners'][$i]['data']->text_color)){ $text_style .= 'color: '.$data['popup_banners'][$i]['data']->text_color.'; '; } if(!empty($data['popup_banners'][$i]['data']->text_bg_color)){ $text_style .= 'background-color: '.$data['popup_banners'][$i]['data']->text_bg_color.';'; } $data['popup_banners'][$i]['text_style'] = $text_style; // if(!empty($data['popup_banners'][$i]['data']->button_color)){ $button_style .= 'background-color: '.$data['popup_banners'][$i]['data']->button_color.'; '; } if(!empty($data['popup_banners'][$i]['data']->button_text_color)){ $button_style .= 'color: '.$data['popup_banners'][$i]['data']->button_text_color.';'; } $data['popup_banners'][$i]['button_style'] = $button_style; } } //fix_banners $data['fix_banner'] = $this->FixBanners->find() ->where(['FixBanners.company_id' => $company->id]) ->where(['FixBanners.delete_flag' => 0]) ->first(); // $data['lp_template_type'] = ''; if($data['newpage']->ai_flag == 3 || $data['newpage']->ai_flag == 4){ $ai_response = json_decode($data['newpage']->ai_response, true); $data['lp_template_type'] = $ai_response['selected_template']; } // $this->set('is_hybrid', $is_hybrid); $this->set('setting', $data['setting']); //データセット $this->set('data', $data); } } public function blockToHtml($company_id, $subdomain, $newblock_id, $slug_plus = null, $fixed_slug = null, $form_error_message = null, $logo_image = null, $contact_gallery_id = null, $cms_version = null, $contact_recruit_id = null, $newpage_id = null, $page_num = null){ $session = $this->request->getSession(); // if($company_id >= 4319){ $cms_version = 2; } // $newblock = $this->Newblocks->find() ->contain(['Newblockbases', 'Newblockoriginals']) ->where(['Newblocks.id' => $newblock_id]) ->where(['Newblocks.company_id' => $company_id]) ->where(['Newblocks.delete_flag' => 0]) ->first(); // $html = ''; if(!empty($newblock)){ // $html = $newblock->newblockbase->html; $contents = json_decode($newblock->contents,true); // $data = []; $data['newblock_id'] = $newblock_id; switch($newblock->blocktype){ case 'block_gallery': $data['html'] = '{gallery_loop}'; $data['gallery_kind'] = $contents['gallery_kind']; $data['gallery_num'] = $contents['gallery_num']; $data['gallery_display_format'] = $contents['gallery_display_format']; $data['gallery_category'] = $contents['gallery_category']; $data['category_select_flag'] = $contents['category_select_flag']; break; case 'block_gallery2': $data['html'] = '{gallery_loop}'; $data['gallery_kind'] = $contents['gallery_kind']; $data['gallery_num'] = $contents['gallery_num']; $data['gallery_display_format'] = $contents['gallery_display_format']; $data['gallery_category'] = $contents['gallery_category']; $data['category_select_flag'] = $contents['category_select_flag']; break; case 'block_gallery3': $data['html'] = '{gallery_loop}'; $data['gallery_kind'] = $contents['gallery_kind']; $data['gallery_num'] = $contents['gallery_num']; $data['gallery_display_format'] = $contents['gallery_display_format']; $data['gallery_category'] = $contents['gallery_category']; $data['category_select_flag'] = $contents['category_select_flag']; break; case 'block_gallery4': $data['html'] = '{gallery_loop}'; $data['gallery_kind'] = $contents['gallery_kind']; $data['gallery_num'] = $contents['gallery_num']; $data['gallery_display_format'] = $contents['gallery_display_format']; $data['gallery_category'] = $contents['gallery_category']; $data['category_select_flag'] = $contents['category_select_flag']; break; case 'block_gallery5': $data['html'] = '{gallery_loop}'; $data['gallery_kind'] = $contents['gallery_kind']; $data['gallery_num'] = $contents['gallery_num']; $data['gallery_display_format'] = $contents['gallery_display_format']; $data['gallery_category'] = $contents['gallery_category']; $data['category_select_flag'] = $contents['category_select_flag']; break; case 'block_menu': $data['html'] = '{menu_loop}'; $data['menu_num'] = $contents['menu_num']; $data['menu_category'] = $contents['menu_category']; break; case 'block_coupon': $data['html'] = '{coupon_loop}'; $data['coupon_items'] = $contents['coupon_items']; break; case 'block_recruit': $data['html'] = '{recruit_loop}'; $data['recruit_num'] = $contents['recruit_num']; $data['recruit_display_type'] = $contents['recruit_display_type']; $data['recruit_category'] = $contents['recruit_category']; $data['recruit_id'] = $contents['recruit_id']; if(isset($contents['category_select_flag'])){ $data['category_select_flag'] = $contents['category_select_flag']; }else{ $data['category_select_flag'] = 0; } break; case 'block_form': $data['html'] = '{contact_loop}'; $data['contact_id'] = $contents['contact_id']; break; case 'block_staff': $data['html'] = '{staff_loop}'; $data['staff_num'] = $contents['staff_num']; $data['staff_display_format'] = $contents['staff_display_format']; $data['staff_category'] = $contents['staff_category']; break; case 'block_question': $data['html'] = '{question_loop}'; $data['question_num'] = $contents['question_num']; $data['question_category'] = $contents['question_category']; break; case 'block_blog': $data['html'] = '{blog_loop}'; $data['blog_kind'] = $contents['blog_kind']; $data['blog_num'] = $contents['blog_num']; if(isset($contents['blog_category'])){ $data['blog_category'] = $contents['blog_category']; }else{ $data['blog_category'] = ''; } if(isset($contents['category_select_flag'])){ $data['category_select_flag'] = $contents['category_select_flag']; }else{ $data['category_select_flag'] = 0; } break; case 'block_blog2': $data['html'] = '{blog_loop}'; $data['blog_kind'] = $contents['blog_kind']; $data['blog_num'] = $contents['blog_num']; if(isset($contents['blog_category'])){ $data['blog_category'] = $contents['blog_category']; }else{ $data['blog_category'] = ''; } if(isset($contents['category_select_flag'])){ $data['category_select_flag'] = $contents['category_select_flag']; }else{ $data['category_select_flag'] = 0; } break; case 'block_blog3': $data['html'] = '{blog_loop}'; $data['blog_kind'] = $contents['blog_kind']; $data['blog_num'] = $contents['blog_num']; if(isset($contents['blog_category'])){ $data['blog_category'] = $contents['blog_category']; }else{ $data['blog_category'] = ''; } if(isset($contents['category_select_flag'])){ $data['category_select_flag'] = $contents['category_select_flag']; }else{ $data['category_select_flag'] = 0; } break; case 'block_blog4': $data['html'] = '{blog_loop}'; $data['blog_kind'] = $contents['blog_kind']; $data['blog_num'] = $contents['blog_num']; if(isset($contents['blog_category'])){ $data['blog_category'] = $contents['blog_category']; }else{ $data['blog_category'] = ''; } if(isset($contents['category_select_flag'])){ $data['category_select_flag'] = $contents['category_select_flag']; }else{ $data['category_select_flag'] = 0; } break; case 'block_blog5': $data['html'] = '{blog_loop}'; $data['blog_kind'] = $contents['blog_kind']; $data['blog_num'] = $contents['blog_num']; if(isset($contents['blog_category'])){ $data['blog_category'] = $contents['blog_category']; }else{ $data['blog_category'] = ''; } if(isset($contents['category_select_flag'])){ $data['category_select_flag'] = $contents['category_select_flag']; }else{ $data['category_select_flag'] = 0; } break; case 'block_cca': $data['html'] = '{cca_loop}'; $data['cca_num'] = $contents['cca_num']; $data['newpage_id'] = $newpage_id; $data['page_num'] = $page_num; break; case 'block_multigallery': $data['html'] = '{multigallery_loop}'; $data['multigallery_kind'] = $contents['multigallery_kind']; $data['multigallery_num'] = $contents['multigallery_num']; if(isset($contents['multigallery_category'])){ $data['multigallery_category'] = $contents['multigallery_category']; }else{ $data['multigallery_category'] = ''; } if(isset($contents['category_select_flag'])){ $data['category_select_flag'] = $contents['category_select_flag']; }else{ $data['category_select_flag'] = 0; } break; case 'block_multigallery2': $data['html'] = '{multigallery_loop}'; $data['multigallery_kind'] = $contents['multigallery_kind']; $data['multigallery_num'] = $contents['multigallery_num']; if(isset($contents['multigallery_category'])){ $data['multigallery_category'] = $contents['multigallery_category']; }else{ $data['multigallery_category'] = ''; } if(isset($contents['category_select_flag'])){ $data['category_select_flag'] = $contents['category_select_flag']; }else{ $data['category_select_flag'] = 0; } break; case 'block_multigallery3': $data['html'] = '{multigallery_loop}'; $data['multigallery_kind'] = $contents['multigallery_kind']; $data['multigallery_num'] = $contents['multigallery_num']; if(isset($contents['multigallery_category'])){ $data['multigallery_category'] = $contents['multigallery_category']; }else{ $data['multigallery_category'] = ''; } if(isset($contents['category_select_flag'])){ $data['category_select_flag'] = $contents['category_select_flag']; }else{ $data['category_select_flag'] = 0; } break; case 'block_multigallery4': $data['html'] = '{multigallery_loop}'; $data['multigallery_kind'] = $contents['multigallery_kind']; $data['multigallery_num'] = $contents['multigallery_num']; if(isset($contents['multigallery_category'])){ $data['multigallery_category'] = $contents['multigallery_category']; }else{ $data['multigallery_category'] = ''; } if(isset($contents['category_select_flag'])){ $data['category_select_flag'] = $contents['category_select_flag']; }else{ $data['category_select_flag'] = 0; } break; case 'block_multigallery5': $data['html'] = '{multigallery_loop}'; $data['multigallery_kind'] = $contents['multigallery_kind']; $data['multigallery_num'] = $contents['multigallery_num']; if(isset($contents['multigallery_category'])){ $data['multigallery_category'] = $contents['multigallery_category']; }else{ $data['multigallery_category'] = ''; } if(isset($contents['category_select_flag'])){ $data['category_select_flag'] = $contents['category_select_flag']; }else{ $data['category_select_flag'] = 0; } break; case 'block_column': $data['html'] = '{column_loop}'; $data['column_kind'] = $contents['column_kind']; $data['column_num'] = $contents['column_num']; if(isset($contents['column_category'])){ $data['column_category'] = $contents['column_category']; }else{ $data['column_category'] = ''; } if(isset($contents['category_select_flag'])){ $data['category_select_flag'] = $contents['category_select_flag']; }else{ $data['category_select_flag'] = 0; } break; case 'block_column2': $data['html'] = '{column_loop}'; $data['column_kind'] = $contents['column_kind']; $data['column_num'] = $contents['column_num']; if(isset($contents['column_category'])){ $data['column_category'] = $contents['column_category']; }else{ $data['column_category'] = ''; } if(isset($contents['category_select_flag'])){ $data['category_select_flag'] = $contents['category_select_flag']; }else{ $data['category_select_flag'] = 0; } break; case 'block_column3': $data['html'] = '{column_loop}'; $data['column_kind'] = $contents['column_kind']; $data['column_num'] = $contents['column_num']; if(isset($contents['column_category'])){ $data['column_category'] = $contents['column_category']; }else{ $data['column_category'] = ''; } if(isset($contents['category_select_flag'])){ $data['category_select_flag'] = $contents['category_select_flag']; }else{ $data['category_select_flag'] = 0; } break; case 'block_column4': $data['html'] = '{column_loop}'; $data['column_kind'] = $contents['column_kind']; $data['column_num'] = $contents['column_num']; if(isset($contents['column_category'])){ $data['column_category'] = $contents['column_category']; }else{ $data['column_category'] = ''; } if(isset($contents['category_select_flag'])){ $data['category_select_flag'] = $contents['category_select_flag']; }else{ $data['category_select_flag'] = 0; } break; case 'block_column5': $data['html'] = '{column_loop}'; $data['column_kind'] = $contents['column_kind']; $data['column_num'] = $contents['column_num']; if(isset($contents['column_category'])){ $data['column_category'] = $contents['column_category']; }else{ $data['column_category'] = ''; } if(isset($contents['category_select_flag'])){ $data['category_select_flag'] = $contents['category_select_flag']; }else{ $data['category_select_flag'] = 0; } break; case 'block_news': $data['html'] = '{news_loop}'; $data['news_kind'] = $contents['news_kind']; $data['news_num'] = $contents['news_num']; if(isset($contents['news_category'])){ $data['news_category'] = $contents['news_category']; }else{ $data['news_category'] = ''; } if(isset($contents['category_select_flag'])){ $data['category_select_flag'] = $contents['category_select_flag']; }else{ $data['category_select_flag'] = 0; } break; case 'block_news2': $data['html'] = '{news_loop}'; $data['news_kind'] = $contents['news_kind']; $data['news_num'] = $contents['news_num']; if(isset($contents['news_category'])){ $data['news_category'] = $contents['news_category']; }else{ $data['news_category'] = ''; } if(isset($contents['category_select_flag'])){ $data['category_select_flag'] = $contents['category_select_flag']; }else{ $data['category_select_flag'] = 0; } break; case 'block_news3': $data['html'] = '{news_loop}'; $data['news_kind'] = $contents['news_kind']; $data['news_num'] = $contents['news_num']; if(isset($contents['news_category'])){ $data['news_category'] = $contents['news_category']; }else{ $data['news_category'] = ''; } if(isset($contents['category_select_flag'])){ $data['category_select_flag'] = $contents['category_select_flag']; }else{ $data['category_select_flag'] = 0; } break; case 'block_news4': $data['html'] = '{news_loop}'; $data['news_kind'] = $contents['news_kind']; $data['news_num'] = $contents['news_num']; if(isset($contents['news_category'])){ $data['news_category'] = $contents['news_category']; }else{ $data['news_category'] = ''; } if(isset($contents['category_select_flag'])){ $data['category_select_flag'] = $contents['category_select_flag']; }else{ $data['category_select_flag'] = 0; } break; case 'block_news5': $data['html'] = '{news_loop}'; $data['news_kind'] = $contents['news_kind']; $data['news_num'] = $contents['news_num']; if(isset($contents['news_category'])){ $data['news_category'] = $contents['news_category']; }else{ $data['news_category'] = ''; } if(isset($contents['category_select_flag'])){ $data['category_select_flag'] = $contents['category_select_flag']; }else{ $data['category_select_flag'] = 0; } break; case 'block_history': $data['html'] = '{history_loop}'; $data['history_num'] = $contents['history_num']; break; case 'block_shop': $data['html'] = '{shop_loop}'; $data['shop_id'] = $contents['shop_id']; break; case 'block_area': $data['html'] = '{area_loop}'; $data['area_id'] = $contents['area_id']; break; case 'block_comparison': $data['html'] = '{comparison_loop}'; $data['comparison_num'] = $contents['comparison_num']; $data['comparison_display_format'] = $contents['comparison_display_format']; $data['comparison_category'] = $contents['comparison_category']; break; case 'block_youtubelist': $data['html'] = '{youtubelist_loop}'; break; case 'block_comments': $data['html'] = '{comments_item_loop}'; $data['comments_num'] = $contents['comments_num']; $data['location_ids'] = $contents['location_ids']; $data['display_value'] = $contents['display_value']; $data['reply'] = $contents['reply']; break; case 'block_cv': $data['html'] = '{cv_loop}'; $data['cv_id'] = $contents['cv_id']; $data['btn_design_1_flag'] = $contents['btn_design_1_flag']; $data['btn_design_2_flag'] = $contents['btn_design_2_flag']; $data['btn_design_3_flag'] = $contents['btn_design_3_flag']; $data['btn_design_4_flag'] = $contents['btn_design_4_flag']; $data['btn_design_5_flag'] = $contents['btn_design_5_flag']; $data['design_1_flag'] = $contents['design_1_flag']; $data['design_2_flag'] = $contents['design_2_flag']; $data['design_3_flag'] = $contents['design_3_flag']; $data['design_4_flag'] = $contents['design_4_flag']; $data['design_5_flag'] = $contents['design_5_flag']; $data['design_6_flag'] = $contents['design_6_flag']; $data['design_7_flag'] = $contents['design_7_flag']; $data['design_8_flag'] = $contents['design_8_flag']; $data['design_9_flag'] = $contents['design_9_flag']; $data['design_10_flag'] = $contents['design_10_flag']; $data['design_11_flag'] = $contents['design_11_flag']; $data['design_12_flag'] = $contents['design_12_flag']; $data['design_13_flag'] = $contents['design_13_flag']; $data['design_14_flag'] = $contents['design_14_flag']; $data['design_15_flag'] = $contents['design_15_flag']; $data['design_16_flag'] = $contents['design_16_flag']; $data['design_17_flag'] = $contents['design_17_flag']; $data['design_18_flag'] = $contents['design_18_flag']; $data['design_19_flag'] = $contents['design_19_flag']; $data['design_20_flag'] = $contents['design_20_flag']; $data['design_21_flag'] = $contents['design_21_flag']; $data['design_22_flag'] = $contents['design_22_flag']; $data['block_cv_btn1_txt'] = $contents['block_cv_btn1_txt']; $data['block_cv_btn1_bg'] = $contents['block_cv_btn1_bg']; $data['block_cv_btn1_border'] = $contents['block_cv_btn1_border']; $data['block_cv_btn2_txt'] = $contents['block_cv_btn2_txt']; $data['block_cv_btn2_bg'] = $contents['block_cv_btn2_bg']; $data['block_cv_btn2_border'] = $contents['block_cv_btn2_border']; // $data['link_value01'] = $contents['link_value01']; $data['link_value02'] = $contents['link_value02']; break; case 'block_author': $data['html'] = '{author_loop}'; $data['author_id'] = $contents['author_id']; break; case 'block_company': $data['html'] = '{corporation_loop}'; break; } $loop_data = $this->Newtool->loopData($company_id, $data); // if(isset($contents['anchor']) && !empty($contents['anchor'])){ $html = ''.$html; } //ブロックパーツIDの付与 $html = str_replace('{nbp_id}', 'nbp'.$newblock_id.' '.$newblock_id, $html); //※※※画像パス $img_dir_path = '/common/upload_data/'.$subdomain.'/image/'; // preg_match('/{item_loop}(.*?){\/item_loop}/s', $html, $item_loop); // if($newblock->blocktype == 'block_question'){ if(isset($contents['question_accordion']) && $contents['question_accordion'] == 1){ $html = str_replace('{css_class}', 'accordion ', $html); }else{ $html = str_replace('{css_class}', '', $html); } }elseif($newblock->blocktype == 'block_cv'){ $tmp_css_class = ' '; if($contents['btn_design_1_flag'] && $contents['btn_design_1_flag'] == 1){$tmp_css_class .= 'dec_btn_1 ';} if($contents['btn_design_2_flag'] && $contents['btn_design_2_flag'] == 1){$tmp_css_class .= 'dec_btn_2 ';} if($contents['btn_design_3_flag'] && $contents['btn_design_3_flag'] == 1){$tmp_css_class .= 'dec_btn_3 ';} if($contents['btn_design_4_flag'] && $contents['btn_design_4_flag'] == 1){$tmp_css_class .= 'dec_btn_4 ';} if($contents['btn_design_5_flag'] && $contents['btn_design_5_flag'] == 1){$tmp_css_class .= 'dec_btn_5 ';} if($contents['design_1_flag'] && $contents['design_1_flag'] == 1){$tmp_css_class .= 'dec1_1 ';} if($contents['design_2_flag'] && $contents['design_2_flag'] == 1){$tmp_css_class .= 'dec1_2 ';} if($contents['design_3_flag'] && $contents['design_3_flag'] == 1){$tmp_css_class .= 'dec1_3 ';} if($contents['design_4_flag'] && $contents['design_4_flag'] == 1){$tmp_css_class .= 'dec1_4 ';} if($contents['design_5_flag'] && $contents['design_5_flag'] == 1){$tmp_css_class .= 'dec2_1 ';} if($contents['design_6_flag'] && $contents['design_6_flag'] == 1){$tmp_css_class .= 'dec2_2 ';} if($contents['design_7_flag'] && $contents['design_7_flag'] == 1){$tmp_css_class .= 'dec2_3 ';} if($contents['design_8_flag'] && $contents['design_8_flag'] == 1){$tmp_css_class .= 'dec2_4 ';} if($contents['design_9_flag'] && $contents['design_9_flag'] == 1){$tmp_css_class .= 'dec3_1 ';} if($contents['design_10_flag'] && $contents['design_10_flag'] == 1){$tmp_css_class .= 'dec3_2 ';} if($contents['design_11_flag'] && $contents['design_11_flag'] == 1){$tmp_css_class .= 'dec3_3 ';} if($contents['design_12_flag'] && $contents['design_12_flag'] == 1){$tmp_css_class .= 'dec3_4 ';} if($contents['design_13_flag'] && $contents['design_13_flag'] == 1){$tmp_css_class .= 'dec3_5 ';} if($contents['design_14_flag'] && $contents['design_14_flag'] == 1){$tmp_css_class .= 'dec3_6 ';} if($contents['design_15_flag'] && $contents['design_15_flag'] == 1){$tmp_css_class .= 'dec3_7 ';} if($contents['design_16_flag'] && $contents['design_16_flag'] == 1){$tmp_css_class .= 'dec3_8 ';} if($contents['design_17_flag'] && $contents['design_17_flag'] == 1){$tmp_css_class .= 'dec3_9 ';} $html = str_replace('{css_class}', $tmp_css_class, $html); }else{ $html = str_replace('{css_class}', '', $html); } $html = str_replace('{t_align}', 'align-left ', $html);//※※※暫定対応 // if(isset($contents['padding_top']) && $contents['padding_top'] != ''){ $html = str_replace('{padding_top}', ' pt'.$contents['padding_top'], $html); }else{ $html = str_replace('{padding_top}', ' pt60', $html); } if(isset($contents['padding_bottom']) && $contents['padding_bottom'] != ''){ $html = str_replace('{padding_bottom}', ' pb'.$contents['padding_bottom'], $html); }else{ $html = str_replace('{padding_bottom}', ' pb60', $html); } if(isset($contents['delay']) && !empty($contents['delay'])){ $html = str_replace('{delay}', ' '.$contents['delay'].' Active', $html); }else{ $html = str_replace('{delay}', '', $html); } if(isset($contents['content_width']) && !empty($contents['content_width']) && isset($contents['max_width']) && !empty($contents['max_width'])){ $html = str_replace('{content_width}', ' '.$contents['content_width'].' '.$contents['max_width'], $html); }elseif(isset($contents['content_width']) && !empty($contents['content_width'])){ $html = str_replace('{content_width}', ' '.$contents['content_width'], $html); }elseif(isset($contents['max_width']) && !empty($contents['max_width'])){ $html = str_replace('{content_width}', ' '.$contents['max_width'], $html); }else{ $html = str_replace('{content_width}', ' width_full', $html); } if($newblock->blocktype == 'block_staff'){ if(isset($contents['staff_comment_display']) && $contents['staff_comment_display'] == 1){ $html = str_replace('{cotents_hide}', ' cotents_hide', $html); }elseif(isset($contents['staff_comment_display']) && $contents['staff_comment_display'] == 2){ $html = str_replace('{cotents_hide}', ' cotents_hide_sp', $html); }else{ $html = str_replace('{cotents_hide}', '', $html); } }elseif($newblock->blocktype == 'block_menu'){ if(isset($contents['menu_category_comment_display']) && $contents['menu_category_comment_display'] == 1){ $html = str_replace('{cotents_hide}', ' cotents_hide', $html); }elseif(isset($contents['menu_category_comment_display']) && $contents['menu_category_comment_display'] == 2){ $html = str_replace('{cotents_hide}', ' cotents_hide_sp', $html); }else{ $html = str_replace('{cotents_hide}', '', $html); } }elseif($newblock->blocktype == 'block_comparison'){ if(isset($contents['comparison_comment_display']) && $contents['comparison_comment_display'] == 1){ $html = str_replace('{cotents_hide}', ' cotents_hide', $html); }elseif(isset($contents['comparison_comment_display']) && $contents['comparison_comment_display'] == 2){ $html = str_replace('{cotents_hide}', ' cotents_hide_sp', $html); }else{ $html = str_replace('{cotents_hide}', '', $html); } } //繰り返し要素(埋め込みパーツ版) //Gallery if($newblock->blocktype == 'block_gallery' || $newblock->blocktype == 'block_gallery2' || $newblock->blocktype == 'block_gallery3' || $newblock->blocktype == 'block_gallery4' || $newblock->blocktype == 'block_gallery5'){ $parent_gallery = $loop_data['ParentGalleries']; $parent_gallery_others = json_decode($loop_data['ParentGalleries']->others, true); // $gallery_html = ''; preg_match('/{gallery_loop}(.*?){\/gallery_loop}/s', $html, $gallery_loop); preg_match('/{gallery_category_loop}(.*?){\/gallery_category_loop}/s', $html, $gallery_category_loop); preg_match('/{gallery_item_loop}(.*?){\/gallery_item_loop}/s', $html, $gallery_item_loop); //カテゴリーで分けて表示 if($contents['gallery_display_format'] == 1){ foreach($loop_data['Galleries'] as $Galleries){ $tmp_gallery_loop = $gallery_loop[1]; // $gallery_categories = $Galleries['GalleryCategories']; //カテゴリ名の表示 if($contents['gallery_category_display'] == 2){ // $tmp_gallery_category = str_replace('{title}', $gallery_categories[0]['name'], $gallery_category_loop[1]); //カテゴリ別名が存在する場合 if($gallery_categories[0]['abbr'] != ''){ $tmp_gallery_category = str_replace('{subtitlearea}', '', $tmp_gallery_category); $tmp_gallery_category = str_replace('{/subtitlearea}', '', $tmp_gallery_category); $tmp_gallery_category = str_replace('{subtitle}', gallery_categories[0].abbr, $tmp_gallery_category); }else{ $tmp_gallery_category = preg_replace('/{subtitlearea}(.*?){\/subtitlearea}/s', '', $tmp_gallery_category); } //$tmp_gallery_loop = $tmp_gallery_loop.replace(gallery_category_loop[0], $tmp_gallery_category); //$tmp_gallery_category = $tmp_gallery_loop.replace(gallery_category_loop[0], $tmp_gallery_category); $gallery_html .= $tmp_gallery_category; //ループ開始前にカテゴリ部分を削除 $tmp_gallery_loop = str_replace($gallery_category_loop[0], '', $tmp_gallery_loop); }else{ $tmp_gallery_loop = preg_replace('/{gallery_category_loop}(.*?){\/gallery_category_loop}/s', '', $tmp_gallery_loop); } //※※※暫定対応 $gallery_html .= '
'; // $galleries = $Galleries['Galleries']; foreach($galleries as $gallery){ $gallery_item = ''; if(!empty($gallery['ext_url'])){ $tmp_gallery_url = ''; if($gallery['ext_target'] == 1){ $tmp_gallery_url = $gallery['ext_url'].'" target="_blank'; }else{ $tmp_gallery_url = $gallery['ext_url']; } $gallery_item = str_replace('{link}', $tmp_gallery_url, $gallery_item_loop[1]); }elseif(isset($parent_gallery_others['other4']) && $parent_gallery_others['other4'] >= 1){ $gallery_item = str_replace('{link}', $parent_gallery->slug_plus.'detail/'.$gallery['id'].'/', $gallery_item_loop[1]); }else{ $gallery_item = str_replace('{link}', $img_dir_path.$gallery['image'], $gallery_item_loop[1]); } if(!empty($gallery['eyecatch_image'])){ $gallery_item = str_replace('{image}', $img_dir_path.$gallery['eyecatch_image'], $gallery_item); }else{ $gallery_item = str_replace('{image}', $img_dir_path.$gallery['image'], $gallery_item); } //$gallery_item = str_replace('{image}', $img_dir_path.$gallery['image'], $gallery_item); $gallery_item = str_replace('{title}', $gallery['name'], $gallery_item); //$gallery_item = str_replace('{title}', galleries[j].name'], $gallery_item); $gallery_item = str_replace('{subtitle}', $gallery['abbr'], $gallery_item); //デザインパターンが3~5で抜粋がある場合 if(!empty($gallery['content']) && ($contents['pattern01'] == 3 || $contents['pattern01'] == 4 || $contents['pattern01'] == 5 || $contents['pattern01'] == 6)){ $gallery_item = str_replace('{gallery_content_area}', '', $gallery_item); $gallery_item = str_replace('{/gallery_content_area}', '', $gallery_item); $gallery_item = str_replace('{content}', $gallery['content'], $gallery_item); }else{ $gallery_item = preg_replace('/{gallery_content_area}(.*?){\/gallery_content_area}/s', '', $gallery_item); } // $gallery_html .= $gallery_item; } //※※※暫定対応 $gallery_html .= '
'; } $html = str_replace($gallery_loop[0], $gallery_html, $html); //一括表示 }else{ //カテゴリ表示部分の削除 $html = str_replace($gallery_category_loop[0], '', $html); $html = str_replace('{gallery_loop}', '', $html); $html = str_replace('{/gallery_loop}', '', $html); // foreach($loop_data['Galleries'] as $Galleries){ $gallery_item = ''; if(!empty($Galleries['ext_url'])){ $tmp_gallery_url = ''; if($Galleries['ext_target'] == 1){ $tmp_gallery_url = $Galleries['ext_url'].'" target="_blank'; }else{ $tmp_gallery_url = $Galleries['ext_url']; } $gallery_item = str_replace('{link}', $tmp_gallery_url, $gallery_item_loop[1]); }elseif(isset($parent_gallery_others['other4']) && $parent_gallery_others['other4'] >= 1){ $gallery_item = str_replace('{link}', $parent_gallery->slug_plus.'detail/'.$Galleries['id'].'/', $gallery_item_loop[1]); }else{ $gallery_item = str_replace('{link}', $img_dir_path.$Galleries['image'], $gallery_item_loop[1]); } if(!empty($Galleries['eyecatch_image'])){ $gallery_item = str_replace('{image}', $img_dir_path.$Galleries['eyecatch_image'], $gallery_item); }else{ $gallery_item = str_replace('{image}', $img_dir_path.$Galleries['image'], $gallery_item); } //$gallery_item = str_replace('{image}', $img_dir_path.$Galleries['image'], $gallery_item); $gallery_item = str_replace('{title}', $Galleries['name'], $gallery_item); //$gallery_item = str_replace('{title}', $Galleries['name'], $gallery_item); $gallery_item = str_replace('{subtitle}', $Galleries['abbr'], $gallery_item); //デザインパターンが5で抜粋がある場合 if(!empty($Galleries['content']) && ($contents['pattern01'] == 3 || $contents['pattern01'] == 4 || $contents['pattern01'] == 5 || $contents['pattern01'] == 6)){ $gallery_item = str_replace('{gallery_content_area}', '', $gallery_item); $gallery_item = str_replace('{/gallery_content_area}', '', $gallery_item); $gallery_item = str_replace('{content}', $Galleries['content'], $gallery_item); }else{ $gallery_item = preg_replace('/{gallery_content_area}(.*?){\/gallery_content_area}/s', '', $gallery_item); } // $gallery_html .= $gallery_item; } $html = str_replace($gallery_item_loop[0], $gallery_html, $html); } } //Menu if($newblock->blocktype == 'block_menu'){ $menu_html = ''; preg_match('/{menu_loop}(.*?){\/menu_loop}/s', $html, $menu_loop); preg_match('/{menu_category_loop}(.*?){\/menu_category_loop}/s', $html, $menu_category_loop); preg_match('/{menu_item_loop}(.*?){\/menu_item_loop}/s', $html, $menu_item_loop); //※※※暫定対応 $menu_html .= '
'; // foreach($loop_data['Menus'] as $Menus){ $tmp_menu_loop = $menu_loop[1]; // $menu_categories = $Menus['MenuCategories']; //※※※暫定対応 $menu_html .= '
'; //カテゴリ名の表示 if($contents['menu_category_display'] == 2){ // $tmp_menu_category = str_replace('{title}', $menu_categories[0]['name'], $menu_category_loop[1]); //カテゴリ別名が存在する場合 if($menu_categories[0]['abbr'] != ''){ $tmp_menu_category = str_replace('{menu_category_subtitlearea}', '', $tmp_menu_category); $tmp_menu_category = str_replace('{/menu_category_subtitlearea}', '', $tmp_menu_category); $tmp_menu_category = str_replace('{subtitle}', $menu_categories[0]['abbr'], $tmp_menu_category); }else{ $tmp_menu_category = preg_replace('/{menu_category_subtitlearea}(.*?){\/menu_category_subtitlearea}/s', '', $tmp_menu_category); } //画像が存在する場合 //if($menu_categories[0]['image01'] != ''){ if($menu_categories[0]['image01'] != '' || $menu_categories[0]['image02'] != '' || $menu_categories[0]['image03'] != ''){ preg_match('/{menu_category_image_area}(.*?){\/menu_category_image_area}/s', $html, $menu_category_img_loop); $menu_category_img = ''; if($menu_categories[0]['image01'] != ''){ $tmp_menu_category_img = ''; $tmp_menu_category_img = str_replace('{menu_category_image_area}', '', $menu_category_img_loop[1]); $tmp_menu_category_img = str_replace('{/menu_category_image_area}', '', $tmp_menu_category_img); $tmp_menu_category_img = str_replace('{title}', $menu_categories[0]['name'], $tmp_menu_category_img); $tmp_menu_category_img = str_replace('{image}', $img_dir_path.$menu_categories[0]['image01'], $tmp_menu_category_img); $menu_category_img .= $tmp_menu_category_img; } if($menu_categories[0]['image02'] != ''){ $tmp_menu_category_img = ''; $tmp_menu_category_img = str_replace('{menu_category_image_area}', '', $menu_category_img_loop[1]); $tmp_menu_category_img = str_replace('{/menu_category_image_area}', '', $tmp_menu_category_img); $tmp_menu_category_img = str_replace('{title}', $menu_categories[0]['name'], $tmp_menu_category_img); $tmp_menu_category_img = str_replace('{image}', $img_dir_path.$menu_categories[0]['image02'], $tmp_menu_category_img); $menu_category_img .= $tmp_menu_category_img; } if($menu_categories[0]['image03'] != ''){ $tmp_menu_category_img = ''; $tmp_menu_category_img = str_replace('{menu_category_image_area}', '', $menu_category_img_loop[1]); $tmp_menu_category_img = str_replace('{/menu_category_image_area}', '', $tmp_menu_category_img); $tmp_menu_category_img = str_replace('{title}', $menu_categories[0]['name'], $tmp_menu_category_img); $tmp_menu_category_img = str_replace('{image}', $img_dir_path.$menu_categories[0]['image03'], $tmp_menu_category_img); $menu_category_img .= $tmp_menu_category_img; } $menu_category_img = '
'.$menu_category_img.'
'; $tmp_menu_category = preg_replace('/{menu_category_image_area}(.*?){\/menu_category_image_area}/s', $menu_category_img, $tmp_menu_category); }else{ $tmp_menu_category = preg_replace('/{menu_category_image_area}(.*?){\/menu_category_image_area}/s', '', $tmp_menu_category); } //カテゴリ説明が存在する場合 if($menu_categories[0]['content'] != ''){ $tmp_menu_category = str_replace('{menu_category_content_area}', '', $tmp_menu_category); $tmp_menu_category = str_replace('{/menu_category_content_area}', '', $tmp_menu_category); $tmp_menu_category = str_replace('{content}', nl2br($menu_categories[0]['content']), $tmp_menu_category); }else{ $tmp_menu_category = preg_replace('/{menu_category_content_area}(.*?){\/menu_category_content_area}/s', '', $tmp_menu_category); } $menu_html .= $tmp_menu_category; //ループ開始前にカテゴリ部分を削除 $tmp_menu_loop = str_replace($menu_category_loop[0], '', $tmp_menu_loop); }else{ $tmp_menu_loop = preg_replace('/{menu_category_loop}(.*?){\/menu_category_loop}/s', '', $tmp_menu_loop); } // //※※※暫定対応 $menu_html .= ''; //※※※暫定対応 $menu_html .= '
'; } //※※※暫定対応 $menu_html .= '
'; // $html = str_replace($menu_loop[0], $menu_html, $html); } //Coupon if($newblock->blocktype == 'block_coupon'){ $coupon_html = ''; preg_match('/{coupon_loop}(.*?){\/coupon_loop}/s', $html, $coupon_loop); foreach($loop_data['Coupons'] as $Coupons){ $coupon_item = ''; //$coupons = loop_data['Coupons']; $coupon_item = str_replace('{title}', $Coupons['name'], $coupon_loop[1]); //内容が存在する場合 if($Coupons['content'] != ''){ $coupon_item = str_replace('{coupon_content_area}', '', $coupon_item); $coupon_item = str_replace('{/coupon_content_area}', '', $coupon_item); $coupon_item = str_replace('{content}', nl2br($Coupons['content']), $coupon_item); }else{ $coupon_item = preg_replace('/{coupon_content_area}(.*?){\/coupon_content_area}/s', '', $coupon_item); } //利用条件が存在する場合 if($Coupons['t_use'] != ''){ $coupon_item = str_replace('{coupon_use_area}', '', $coupon_item); $coupon_item = str_replace('{/coupon_use_area}', '', $coupon_item); $coupon_item = str_replace('{use}', nl2br($Coupons['t_use']), $coupon_item); }else{ $coupon_item = preg_replace('/{coupon_use_area}(.*?){\/coupon_use_area}/s', '', $coupon_item); } //有効期限が存在する場合 if($Coupons['term']){ $coupon_item = str_replace('{coupon_term_area}', '', $coupon_item); $coupon_item = str_replace('{/coupon_term_area}', '', $coupon_item); $coupon_item = str_replace('{term}', $Coupons['term'], $coupon_item); }else{ $coupon_item = preg_replace('/{coupon_term_area}(.*?){\/coupon_term_area}/s', '', $coupon_item); } // $coupon_html .= $coupon_item; } $html = str_replace($coupon_loop[0], $coupon_html, $html); } //Recruit if($newblock->blocktype == 'block_recruit'){ $recruit_html = ''; preg_match('/{recruit_loop}(.*?){\/recruit_loop}/s', $html, $recruit_loop); //一覧表示 if($contents['recruit_display_type'] == 1){ // if($loop_data['Recruits']['parent'] && !empty($loop_data['Recruits']['parent']->slug)){ $parent_slug = $loop_data['Recruits']['parent']->slug; }else{ $parent_slug = 'recruit'; } // foreach($loop_data['Recruits']['detail'] as $Recruits){ $recruit_item = ''; $recruit_item = str_replace('{title}', $Recruits['title'], $recruit_loop[1]); $recruit_item = str_replace('{contents}', $Recruits['contents'], $recruit_item); if($Recruits['image01'] && $Recruits['image01'] != ''){ $recruit_item = str_replace('{image}', $img_dir_path.$Recruits['image01'], $recruit_item); $recruit_item = str_replace('{no_img}', ' class=""', $recruit_item); }else{ $recruit_item = str_replace('{image}', '/common/public_image/no_image.jpg', $recruit_item); $recruit_item = str_replace('{no_img}', ' class="no_img"', $recruit_item); } //※※※ $recruit_item = str_replace('{link}', '/'.$parent_slug.'/detail/'.$Recruits['id'].'/', $recruit_item); $recruit_item = str_replace('{link}', '/'.$parent_slug.'/detail/'.$Recruits['id'].'/', $recruit_item); $recruit_item = str_replace('{alt}', $Recruits['title'], $recruit_item); // $recruit_html .= $recruit_item; } //詳細表示 }else{ $recruits = $loop_data['Recruits'][0]; $recruit_html = str_replace('{title}', $recruits['title'], $recruit_loop[1]); $recruit_html = str_replace('{content}', $recruits['content'], $recruit_html); $recruit_html = str_replace('{contents}', nl2br($recruits['contents']), $recruit_html); if($recruits['image01'] && $recruits['image01'] != ''){ $recruit_html = str_replace('{image01_area}', '', $recruit_html); $recruit_html = str_replace('{/image01_area}', '', $recruit_html); $recruit_html = str_replace('{image01}', $img_dir_path.$recruits['image01'], $recruit_html); }else{ //$recruit_html = str_replace('{image01}', '/common/public_image/no_image.jpg', $recruit_html); $recruit_html = preg_replace('/{image01_area}(.*?){\/image01_area}/s', '', $recruit_html); } if($recruits['image02'] && $recruits['image02'] != ''){ $recruit_html = str_replace('{image02_area}', '', $recruit_html); $recruit_html = str_replace('{/image02_area}', '', $recruit_html); $recruit_html = str_replace('{image02}', $img_dir_path.$recruits['image02'], $recruit_html); }else{ //$recruit_html = str_replace('{image02}', '/common/public_image/no_image.jpg', $recruit_html); $recruit_html = preg_replace('/{image02_area}(.*?){\/image02_area}/s', '', $recruit_html); } if($recruits['image03'] && $recruits['image03'] != ''){ $recruit_html = str_replace('{image03_area}', '', $recruit_html); $recruit_html = str_replace('{/image03_area}', '', $recruit_html); $recruit_html = str_replace('{image03}', $img_dir_path.$recruits['image03'], $recruit_html); }else{ //$recruit_html = str_replace('{image03}', '/common/public_image/no_image.jpg', $recruit_html); $recruit_html = preg_replace('/{image03_area}(.*?){\/image03_area}/s', '', $recruit_html); } if($recruits['image01alt'] && $recruits['image01alt'] != ''){ $recruit_html = str_replace('{image01alt}', $recruits['image01alt'], $recruit_html); }else{ $recruit_html = str_replace('{image01alt}', '', $recruit_html); } if($recruits['image02alt'] && $recruits['image02alt'] != ''){ $recruit_html = str_replace('{image02alt}', $recruits['image02alt'], $recruit_html); }else{ $recruit_html = str_replace('{image02alt}', '', $recruit_html); } if($recruits['image03alt'] && $recruits['image03alt'] != ''){ $recruit_html = str_replace('{image03alt}', $recruits['image03alt'], $recruit_html); }else{ $recruit_html = str_replace('{image03alt}', '', $recruit_html); } $recruit_html = str_replace('{company_name}', $recruits['company_name'], $recruit_html); $recruit_job_type = str_replace(',', '・', $recruits['job_type']); $recruit_html = str_replace('{job_type}', $recruit_job_type, $recruit_html); $employment_status_array = ['1'=>'正社員','2'=>'パート・アルバイト','3'=>'契約社員','4'=>'派遣社員','5'=>'インターン','6'=>'ボランティア','7'=>'日雇い','8'=>'その他','9'=>'業務委託']; $recruit_html = str_replace('{employment_status}', $employment_status_array[$recruits['employment_status']], $recruit_html); $recruit_html = str_replace('{l_zip3}', $recruits['l_zip3'], $recruit_html); $recruit_html = str_replace('{l_zip4}', $recruits['l_zip4'], $recruit_html); $recruit_html = str_replace('{l_prefecture}', $recruits['l_prefecture'], $recruit_html); $recruit_html = str_replace('{l_city}', $recruits['l_city'], $recruit_html); $recruit_html = str_replace('{l_town}', $recruits['l_town'], $recruit_html); $recruit_html = str_replace('{l_address1}', $recruits['l_address1'], $recruit_html); $recruit_html = str_replace('{l_address2}', $recruits['l_address2'], $recruit_html); $salary_type_array = ['1'=>'月給','2'=>'時給','3'=>'年俸','4'=>'日給','5'=>'週給','6'=>'月収']; $recruit_html = str_replace('{salary_type}', $salary_type_array[$recruits['salary_type']], $recruit_html); $recruit_html = str_replace('{minsalary}', number_format($recruits['minsalary']), $recruit_html); // if($recruits['maxsalary'] != ''){ $recruit_html = str_replace('{maxsalaryarea}', '', $recruit_html); $recruit_html = str_replace('{/maxsalaryarea}', '', $recruit_html); $recruit_html = str_replace('{maxsalary}', number_format($recruits['maxsalary']), $recruit_html); }else{ $recruit_html = preg_replace('/{maxsalaryarea}(.*?){\/maxsalaryarea}/s', '', $recruit_html); } // if($recruits['information'] != ''){ $recruit_html = str_replace('{informationarea}', '', $recruit_html); $recruit_html = str_replace('{/informationarea}', '', $recruit_html); if(strpos($recruits['information'], '@') !== false){ $recruit_html = str_replace('{information}', ''.$recruits['information'].'', $recruit_html); }elseif(preg_match('/^[0-9]{2,4}-[0-9]{2,4}-[0-9]{3,4}$/', $recruits['information'])){ $recruit_html = str_replace('{information}', "".$recruits['information'].'', $recruit_html); }else{ $recruit_html = str_replace('{information}', $recruits['information'], $recruit_html); } }else{ $recruit_html = preg_replace('/{informationarea}(.*?){\/informationarea}/s', '', $recruit_html); } // if($recruits['charge'] != ''){ $recruit_html = str_replace('{chargearea}', '', $recruit_html); $recruit_html = str_replace('{/chargearea}', '', $recruit_html); $recruit_html = str_replace('{charge}', $recruits['charge'], $recruit_html); }else{ $recruit_html = preg_replace('/{chargearea}(.*?){\/chargearea}/s', '', $recruit_html); } if($recruits['content_json'] != ''){ $recruit_contents = json_decode($recruits['content_json'], true); }else{ $recruit_contents = ''; } // preg_match('/{recruit_item_loop}(.*?){\/recruit_item_loop}/s', $html, $recruit_item_loop); $recruit_item = ''; if($recruit_contents){ // foreach($recruit_contents as $recruit_content){ $tmp_recruit_item = ''; // if(!empty($recruit_content['name']) && !empty($recruit_content['content'])){ $tmp_recruit_item = str_replace('{recruit_item_title}', $recruit_content['name'], $recruit_item_loop[1]); $tmp_recruit_item = str_replace('{recruit_item_content}', nl2br($recruit_content['content']), $tmp_recruit_item); } $recruit_item .= $tmp_recruit_item; } } //$recruit_html .= $recruit_item; $recruit_html = str_replace($recruit_item_loop[0], $recruit_item, $recruit_html); $recruit_html = str_replace('{recruit_loop}', '', $recruit_html); $recruit_html = str_replace('{/recruit_loop}', '', $recruit_html); } $html = str_replace($recruit_loop[0], $recruit_html, $html); } //Contact if($newblock->blocktype == 'block_form'){ //確認画面の場合 if($fixed_slug == 'form_conf'){ //$tmp_form_data = $this->Cookie->read('ipp_lambda_form'); $tmp_form_data = $session->read('ipp_lambda_form'); //$data['form_input_data'] = $tmp_form_data['form_data']; //$data['back_url'] = $tmp_form_data['back_url']; //var_dump($tmp_form_data['form_data']); // $html .= ''; $html .= ''; //※※※イレギュラー処理、先に説明文とプライバシーポリシーを処理 $contact_data = $loop_data['Contacts'][0]; // /*if(!empty($contact_data['grv3_sitekey']) && !empty($contact_data['grv3_secretkey'])){ $recaptchaToken = $tmp_form_data['form_data']['recaptchaToken']; $params = array( 'secret' => $contact_data['grv3_secretkey'], 'response' => $recaptchaToken, ); $url = 'https://www.google.com/recaptcha/api/siteverify?'; $url .= http_build_query($params); $ch = curl_init(); curl_setopt( $ch, CURLOPT_URL, $url ); curl_setopt( $ch, CURLOPT_HEADER, false ); curl_setopt( $ch, CURLOPT_RETURNTRANSFER, true ); curl_setopt( $ch, CURLOPT_TIMEOUT, 120 ); $response = curl_exec( $ch ); curl_close( $ch ); $verify = json_decode($response); if($verify->success) { //var_dump('true'); } else { //var_dump('false'); //return $this->redirect('/', '301'); $contact_redirect_url = explode('form_conf', $_SERVER['REQUEST_URI']); return $this->redirect($contact_redirect_url[0], '301'); } }*/ // //if($newblock_id == $form_block_id){ //説明文が存在する場合 $html = preg_replace('/{contact_content_area}(.*?){\/contact_content_area}/s', '', $html); //プライバシーポリシーが存在する場合 $html = preg_replace('/{contact_privacy_area}(.*?){\/contact_privacy_area}/s', '', $html); // $html = str_replace('{submit_button_id}', 'form_submit'.$contact_data['id'], $html); $html = str_replace('{submit_button_label}', '送信する', $html); $html = str_replace('{back_button}', '', $html); $html = str_replace('{/back_button}', '', $html); $html = str_replace('{contact_script}', "", $html); //フォームのactionやhiddenタグ //$form_start = $this->Form->create(null, ['name'=>'MainForm', 'type'=>'file', 'url'=>$slug_plus.'#form_'.$newblock->id]); $form_start = '
'; // if(!empty($contact_data['grv3_sitekey']) && !empty($contact_data['grv3_secretkey'])){ $form_start .= ''; } $html = str_replace('{form_start}', $form_start, $html); //$form_end = $this->Form->end(['data-type' => 'hidden']); //$form_end = '
'; // if(!empty($contact_data['grv3_sitekey']) && !empty($contact_data['grv3_secretkey'])){ // $html = str_replace('{reCAPTCHA}', '

このサイトはreCAPTCHAとGoogleによって保護されており、Googleのプライバシーポリシー利用規約が適用されます

', $html); // if($contact_data['recaptcha_flag'] == 1){ $form_end = " "; }else{ $form_end = " "; } }else{ // $html = str_replace('{reCAPTCHA}', '', $html); // $form_end = ''; } $html = str_replace('{form_end}', $form_end, $html); $hidden_data = ''; $hidden_data .= ''; //$hidden_data = ''; $hidden_data .= ''; $hidden_data .= ''; $html = str_replace('{hiddenarea}', $hidden_data, $html); // $contact_html = ''; $contact_html .= '
'; $contact_html .= '
'; $contact_html .= '

入力内容をご確認の上、『送信する』ボタンを押してください。

'; $contact_html .= '
'; $contact_html .= '
'; preg_match('/{contact_loop}(.*?){\/contact_loop}/s', $html, $contact_loop); // if(isset($tmp_form_data['form_data']['contact_gallery_id']) && !empty($tmp_form_data['form_data']['contact_gallery_id'])){ // $contact_gallery_html = ''; $contact_gallery_html .= ''; $contact_gallery_html .= ''; $contact_gallery_html .= ''; $contact_gallery_html .= '
'; $contact_gallery_html .= '
URL
'; $contact_gallery_html .= '
'.$tmp_form_data['form_data']['contact_gallery_url'].'
'; $contact_gallery_html .= '
'; $contact_gallery_html .= '
'; $contact_gallery_html .= '
タイトル
'; $contact_gallery_html .= '
'.$tmp_form_data['form_data']['contact_gallery_name'].'
'; $contact_gallery_html .= '
'; $contact_gallery_html .= '
'; $contact_gallery_html .= '
説明
'; $contact_gallery_html .= '
'.$tmp_form_data['form_data']['contact_gallery_content'].'
'; $contact_gallery_html .= '
'; $contact_html = $contact_html.$contact_gallery_html; } // if(isset($tmp_form_data['form_data']['contact_recruit_id']) && !empty($tmp_form_data['form_data']['contact_recruit_id'])){ // $contact_recruit_html = ''; $contact_recruit_html .= ''; $contact_recruit_html .= ''; $contact_recruit_html .= ''; $contact_recruit_html .= '
'; $contact_recruit_html .= '
URL
'; $contact_recruit_html .= '
'.$tmp_form_data['form_data']['contact_recruit_url'].'
'; $contact_recruit_html .= '
'; $contact_recruit_html .= '
'; $contact_recruit_html .= '
タイトル
'; $contact_recruit_html .= '
'.$tmp_form_data['form_data']['contact_recruit_name'].'
'; $contact_recruit_html .= '
'; $contact_recruit_html .= '
'; $contact_recruit_html .= '
説明
'; $contact_recruit_html .= '
'.$tmp_form_data['form_data']['contact_recruit_content'].'
'; $contact_recruit_html .= '
'; $contact_html = $contact_html.$contact_recruit_html; } //$contact_item_loop = $html.match(/\{$contact_item_loop\}([\s\S]*?){\/$contact_item_loop\}/); // $cd_num = 1; foreach($loop_data['Contacts'][0]['contact_details'] as $contact_detail){ $contact_item = ''; $contact_item = str_replace('{title}', $contact_detail['name'], $contact_loop[1]); // /*if($contact_detail['type'] == 'textarea'){ $contact_item = str_replace('{content}', nl2br($tmp_form_data['form_data'][$contact_detail['id']]), $contact_item); }elseif($contact_detail['type'] == 'image'){ $contact_item = str_replace('{content}', $tmp_form_data['form_data'][$contact_detail['id']]['name'], $contact_item); }elseif($contact_detail['type'] == 'checkbox'){ $contact_item = str_replace('{content}', implode('、', $tmp_form_data['form_data'][$contact_detail['id']]), $contact_item); }else{ $contact_item = str_replace('{content}', $tmp_form_data['form_data'][$contact_detail['id']], $contact_item); } $contact_item = str_replace('{error}', '', $contact_item); // $contact_html .= $contact_item;*/ if(isset($tmp_form_data['form_data'][$contact_detail['id']]) && is_array($tmp_form_data['form_data'][$contact_detail['id']]) && $contact_detail['type'] != 'image' && $contact_detail['type'] != 'birthday'){ $tmp_form_data['form_data'][$contact_detail['id']] = array_filter($tmp_form_data['form_data'][$contact_detail['id']], "strlen"); $display_val = implode('、',$tmp_form_data['form_data'][$contact_detail['id']]); $hidden_val = ''; foreach($tmp_form_data['form_data'][$contact_detail['id']] as $key=>$val){ $hidden_val .= ''; } }else{ if($contact_detail['type'] == 'textarea'){ $display_val = nl2br($tmp_form_data['form_data'][$contact_detail['id']]); $hidden_val = ''; }elseif($contact_detail['type'] == 'image'){ if(!empty($tmp_form_data['form_data'][$contact_detail['id']]['tmp_file_name'])){ if($tmp_form_data['form_data'][$contact_detail['id']]['type'] == 'application/pdf'){ $display_val = ''; }else{ $display_val = '
'; } $display_val .= $tmp_form_data['form_data'][$contact_detail['id']]['name']; $hidden_val = ''; $hidden_val .= ''; $hidden_val .= ''; $hidden_val .= ''; $hidden_val .= ''; }else{ $display_val = ''; $hidden_val = ''; } }elseif($contact_detail['type'] == 'date' || $contact_detail['type'] == 'datetime'){ if(!empty($tmp_form_data['form_data'][$contact_detail['id']])){ $datetime = ''; $tmp_datetime = ''; $tmp_date = ''; $tmp_date_w = ''; $w = ''; $tmp_date = substr($tmp_form_data['form_data'][$contact_detail['id']], 0, 10); $tmp_datetime = date_create($tmp_date); $week = ['日', '月', '火', '水', '木', '金', '土']; $w = (int)date_format($tmp_datetime, 'w'); $tmp_date_w = $tmp_date.' ('.$week[$w].')'; $datetime = str_replace($tmp_date, $tmp_date_w, $tmp_form_data['form_data'][$contact_detail['id']]); $display_val = $datetime; $hidden_val = ''; }else{ $display_val = $tmp_form_data['form_data'][$contact_detail['id']]; $hidden_val = ''; } }elseif($contact_detail['type'] == 'birthday'){ $display_val = $tmp_form_data['form_data'][$contact_detail['id']]['year'].'年'.$tmp_form_data['form_data'][$contact_detail['id']]['month'].'月'.$tmp_form_data['form_data'][$contact_detail['id']]['day'].'日'; $hidden_val = ''; }else{ $display_val = $tmp_form_data['form_data'][$contact_detail['id']]; $hidden_val = ''; } } $contact_item = str_replace('{content}', $display_val.$hidden_val, $contact_item); $contact_item = str_replace('{error}', '', $contact_item); // $contact_html .= $contact_item; $cd_num++; } // $html = str_replace($contact_loop[0], $contact_html, $html); $html = ''.$html; /*}else{ $html = ''; }*/ //送信完了画面の場合 }elseif($fixed_slug == 'form_send'){ $contact_data = $loop_data['Contacts'][0]; $html = ''; $html .= '
'; $html .= '
'; //$html .= '
'; //$html .= '

'; //$html .= '

'; //$html .= '
'; $html .= '
'; $html .= '
'; $html .= '

'.nl2br($contact_data['done_message']).'

'; if(!empty($contact_data['conversion_tag'])){ $html .= $contact_data['conversion_tag']; } $html .= '
'; $html .= '
'; $html .= '
'; $html .= '
'; $html = ''.$html; $html = str_replace('{reCAPTCHA}', '', $html); /*

*/ //送信前の画面の場合 }else{ // //$tmp_form_data = $this->Cookie->read('ipp_lambda_form'); $tmp_form_data = $session->read('ipp_lambda_form'); // $html = ''.$html; //※※※イレギュラー処理、先に説明文とプライバシーポリシーを処理 $contact_data = $loop_data['Contacts'][0]; //説明文が存在する場合 if($contact_data['content'] != ''){ $html = str_replace('{contact_content_area}', '', $html); $html = str_replace('{/contact_content_area}', '', $html); $contact_content = nl2br($contact_data['content']); $html = str_replace('{contents}', $contact_content, $html); }else{ $html = preg_replace('/{contact_content_area}(.*?){\/contact_content_area}/s', '', $html); } //プライバシーポリシーが存在する場合 if($contact_data['privacy_text'] != ''){ $html = str_replace('{contact_privacy_area}', '', $html); $html = str_replace('{/contact_privacy_area}', '', $html); $contact_privacy = nl2br($contact_data['privacy_text']); $html = str_replace('{privacy}', $contact_privacy, $html); }else{ $html = preg_replace('/{contact_privacy_area}(.*?){\/contact_privacy_area}/s', '', $html); } // $html = str_replace('{submit_button_id}', 'form_submit'.$contact_data['id'], $html); $html = str_replace('{submit_button_label}', '入力内容を確認する', $html); $html = preg_replace('/{back_button}(.*?){\/back_button}/s', '', $html); if(!empty($contact_data['grv3_sitekey']) && !empty($contact_data['grv3_secretkey'])){ // $html = str_replace('{reCAPTCHA}', '', $html); // $contact_script = ""; }else{ $html = str_replace('{reCAPTCHA}', '', $html); $contact_script = ""; } $html = str_replace('{contact_script}', $contact_script, $html); //フォームのactionやhiddenタグ //$form_start = $this->Form->create(null, ['name'=>'MainForm', 'type'=>'file', 'url'=>$slug_plus.'#form_'.$newblock->id]); $form_start = '
'; // /*if(!empty($contact_data['grv3_sitekey']) && !empty($contact_data['grv3_secretkey'])){ $form_start .= ''; }*/ $html = str_replace('{form_start}', $form_start, $html); //$form_end = $this->Form->end(['data-type' => 'hidden']); // /*if(!empty($contact_data['grv3_sitekey']) && !empty($contact_data['grv3_secretkey'])){ $form_end = "
"; }else{ $form_end = ''; }*/ $form_end = ''; $html = str_replace('{form_end}', $form_end, $html); $hidden_data = ''; $hidden_data .= ''; //$hidden_data = ''; $hidden_data .= ''; $hidden_data .= ''; $html = str_replace('{hiddenarea}', $hidden_data, $html); // $contact_html = ''; preg_match('/{contact_loop}(.*?){\/contact_loop}/s', $html, $contact_loop); //$contact_item_loop = $html.match(/\{$contact_item_loop\}([\s\S]*?){\/$contact_item_loop\}/); // $cd_num = 1; foreach($loop_data['Contacts'][0]['contact_details'] as $contact_detail){ $contact_item = ''; if($contact_detail['required'] == 1){ $title = $contact_detail['name'].''; }else{ $title = $contact_detail['name']; } $contact_item = str_replace('{title}', $title, $contact_loop[1]); // $form_value = ''; if($contact_detail['type'] == 'birthday' && isset($tmp_form_data['form_data'][$contact_detail['id']])){ $form_value = ''; $form_value_year = $tmp_form_data['form_data'][$contact_detail['id']]['year']; $form_value_month = $tmp_form_data['form_data'][$contact_detail['id']]['month']; $form_value_day = $tmp_form_data['form_data'][$contact_detail['id']]['day']; }elseif(isset($tmp_form_data['form_data'][$contact_detail['id']])){ $form_value = $tmp_form_data['form_data'][$contact_detail['id']]; }else{ $form_value = ''; $form_value_year = ''; $form_value_month = ''; $form_value_day = ''; } // if($contact_data['remark_flag'] == 1){ if($contact_detail['type'] == 'text'){ $contact_item = str_replace('{content}', '

'.nl2br($contact_detail['remarks']).'

', $contact_item); }else if($contact_detail['type'] == 'textarea'){ $contact_item = str_replace('{content}', '

'.nl2br($contact_detail['remarks']).'

', $contact_item); }else if($contact_detail['type'] == 'mail'){ $contact_item = str_replace('{content}', '

'.nl2br($contact_detail['remarks']).'

', $contact_item); //確認用メールアドレスの処理 if($contact_detail['required'] == 1 && $contact_detail['content'] == 1){ $form_value2 = ''; if(isset($tmp_form_data['form_data']['re_'.$contact_detail['id']])){ $form_value2 = $tmp_form_data['form_data']['re_'.$contact_detail['id']]; }else{ $form_value2 = ''; } $tmp_contact_item = ''; $tmp_contact_item = $contact_loop[1]; $tmp_contact_item = str_replace('{error}', '{error2}', $tmp_contact_item); $contact_item = $contact_item.$tmp_contact_item; $contact_item = str_replace('{title}', $contact_detail['name'].' (確認用)', $contact_item); $contact_item = str_replace('{content}', '

'.nl2br($contact_detail['remarks']).'

', $contact_item); } }else if($contact_detail['type'] == 'radio'){ $form_arrays = explode(',', $contact_detail['content']); $form_array_content = ''; foreach($form_arrays as $key=>$val){ $form_checked = ''; if(isset($form_value) && $form_value == $val){ $form_checked = ' checked'; }else{ $form_checked = ''; } $form_array_content .= ''; } $contact_item = str_replace('{content}', $form_array_content.'

'.nl2br($contact_detail['remarks']).'

', $contact_item); }else if($contact_detail['type'] == 'checkbox'){ $form_arrays = explode(',', $contact_detail['content']); $form_array_content = ''; foreach($form_arrays as $key=>$val){ $form_checked = ''; if(isset($form_value) && $form_value == $val){ $form_checked = ' checked'; }else{ //$form_checked = ''; } $form_array_content .= ''; } $contact_item = str_replace('{content}', $form_array_content.'

'.nl2br($contact_detail['remarks']).'

', $contact_item); }else if($contact_detail['type'] == 'select'){ $form_arrays = explode(',', $contact_detail['content']); $form_array_content = ''; $form_array_content .= ''; $contact_item = str_replace('{content}', $form_array_content.'

'.nl2br($contact_detail['remarks']).'

', $contact_item); }else if($contact_detail['type'] == 'date'){ $contact_item = str_replace('{content}', '

'.nl2br($contact_detail['remarks']).'

', $contact_item); }else if($contact_detail['type'] == 'datetime'){ $contact_item = str_replace('{content}', '

'.nl2br($contact_detail['remarks']).'

', $contact_item); }else if($contact_detail['type'] == 'zip'){ $contact_item = str_replace('{content}', '

'.nl2br($contact_detail['remarks']).'

', $contact_item); }else if($contact_detail['type'] == 'address'){ $contact_item = str_replace('{content}', '

'.nl2br($contact_detail['remarks']).'

', $contact_item); }else if($contact_detail['type'] == 'image'){ $contact_item = str_replace('{content}', '

'.nl2br($contact_detail['remarks']).'

', $contact_item); }elseif($contact_detail['type'] == 'birthday'){ $contact_item = str_replace('{content}', '

'.nl2br($contact_detail['remarks']).'

', $contact_item); }else{ } }else{ if($contact_detail['type'] == 'text'){ $contact_item = str_replace('{content}', '', $contact_item); }else if($contact_detail['type'] == 'textarea'){ $contact_item = str_replace('{content}', '', $contact_item); }else if($contact_detail['type'] == 'mail'){ $contact_item = str_replace('{content}', '', $contact_item); //確認用メールアドレスの処理 if($contact_detail['required'] == 1 && $contact_detail['content'] == 1){ $form_value2 = ''; if(isset($tmp_form_data['form_data']['re_'.$contact_detail['id']])){ $form_value2 = $tmp_form_data['form_data']['re_'.$contact_detail['id']]; }else{ $form_value2 = ''; } $tmp_contact_item = ''; $tmp_contact_item = $contact_loop[1]; $tmp_contact_item = str_replace('{error}', '{error2}', $tmp_contact_item); $contact_item = $contact_item.$tmp_contact_item; $contact_item = str_replace('{title}', $contact_detail['name'].' (確認用)', $contact_item); $contact_item = str_replace('{content}', '', $contact_item); } }else if($contact_detail['type'] == 'radio'){ $form_arrays = explode(',', $contact_detail['content']); $form_array_content = ''; foreach($form_arrays as $key=>$val){ $form_checked = ''; if(isset($form_value) && $form_value == $val){ $form_checked = ' checked'; }else{ $form_checked = ''; } $form_array_content .= ''; } $contact_item = str_replace('{content}', $form_array_content, $contact_item); }else if($contact_detail['type'] == 'checkbox'){ $form_arrays = explode(',', $contact_detail['content']); $form_array_content = ''; foreach($form_arrays as $key=>$val){ $form_checked = ''; if(!empty($form_value)){ foreach($form_value as $key2=>$val2){ if(isset($val2) && $val2 == $val){ $form_checked = ' checked'; }else{ //$form_checked = ''; } } } $form_array_content .= ''; } $contact_item = str_replace('{content}', $form_array_content, $contact_item); }else if($contact_detail['type'] == 'select'){ $form_arrays = explode(',', $contact_detail['content']); $form_array_content = ''; $form_array_content .= ''; $contact_item = str_replace('{content}', $form_array_content, $contact_item); }else if($contact_detail['type'] == 'date'){ $contact_item = str_replace('{content}', ' ', $contact_item); }else if($contact_detail['type'] == 'datetime'){ $contact_item = str_replace('{content}', ' ', $contact_item); }else if($contact_detail['type'] == 'zip'){ $contact_item = str_replace('{content}', '', $contact_item); }else if($contact_detail['type'] == 'address'){ $contact_item = str_replace('{content}', ' ', $contact_item); }else if($contact_detail['type'] == 'image'){ $contact_item = str_replace('{content}', '', $contact_item); }elseif($contact_detail['type'] == 'birthday'){ $contact_item = str_replace('{content}', '
', $contact_item); }else{ } } if(isset($form_error_message[$contact_detail['id']]) && !empty($form_error_message[$contact_detail['id']])){ $contact_item = str_replace('{error}', '

'.$form_error_message[$contact_detail['id']].'

', $contact_item); }else{ $contact_item = str_replace('{error}', '', $contact_item); } if(isset($form_error_message['re_'.$contact_detail['id']]) && !empty($form_error_message['re_'.$contact_detail['id']])){ $contact_item = str_replace('{error2}', '

'.$form_error_message['re_'.$contact_detail['id']].'

', $contact_item); }else{ $contact_item = str_replace('{error2}', '', $contact_item); } // $contact_html .= $contact_item; $cd_num++; } //パラメータにギャラリーIDがある場合 if(!empty($contact_gallery_id)){ $contact_gallery_data = $this->Galleries->find() ->where(['Galleries.id' => $contact_gallery_id]) ->where(['Galleries.company_id' => $company_id]) ->where(['Galleries.delete_flag' => 0]) ->first(); if(!empty($contact_gallery_data)){ $contact_company = $this->Companies->find() ->where(['Companies.id' => $company_id]) ->where(['Companies.delete_flag' => 0]) ->first(); $contact_gallery_query = $this->Newpages->find() ->where(['Newpages.company_id' => $company_id]) ->where(['Newpages.pagetype_id' => 8]) ->where(['Newpages.delete_flag' => 0]); //ギャラリー複数化 if(!empty($contact_gallery_data->gallery_kind)){ $contact_gallery_query->where(['Newpages.page_kind' => $contact_gallery_data->gallery_kind]); }else{ $contact_gallery_query->where(['OR' => [['Newpages.page_kind' => ''], ['Newpages.page_kind IS NULL']]]); } $contact_gallery_page = $contact_gallery_query->first(); // $contact_gallery_html = ''; $contact_gallery_html .= ''; $contact_gallery_html .= ''; $contact_gallery_html .= ''; $contact_gallery_html .= '
'; $contact_gallery_html .= '
URL
'; if(!empty($contact_company->domain)){ $contact_gallery_html .= '
https://'.$contact_company->domain.'/'.$contact_gallery_page->slug.'/detail/'.$contact_gallery_data->id.'/
'; }else{ if(SV_KIND2 == 'IPP3_1'){ $contact_gallery_html .= '
https://'.$contact_company->subdomain.'.onerank-cms.com/'.$contact_gallery_page->slug.'/detail/'.$contact_gallery_data->id.'/
'; }elseif(SV_KIND2 == 'IPP3_2'){ $contact_gallery_html .= '
https://'.$contact_company->subdomain.'.onerank-cms-2.com/'.$contact_gallery_page->slug.'/detail/'.$contact_gallery_data->id.'/
'; }elseif(SV_KIND2 == 'IPP3_3'){ $contact_gallery_html .= '
https://'.$contact_company->subdomain.'.onerank-cms-3.com/'.$contact_gallery_page->slug.'/detail/'.$contact_gallery_data->id.'/
'; }elseif(SV_KIND2 == 'dev(AWS)'){ $contact_gallery_html .= '
https://'.$contact_company->subdomain.'.onerank-hybrid-dev.com/'.$contact_gallery_page->slug.'/detail/'.$contact_gallery_data->id.'/
'; }elseif(SV_KIND2 == 'dev2(AWS)'){ $contact_gallery_html .= '
https://'.$contact_company->subdomain.'.onerank-hybrid-dev2.com/'.$contact_gallery_page->slug.'/detail/'.$contact_gallery_data->id.'/
'; }elseif(SV_KIND2 == 'dev3(AWS)'){ $contact_gallery_html .= '
https://'.$contact_company->subdomain.'.onerank-hybrid-dev3.com/'.$contact_gallery_page->slug.'/detail/'.$contact_gallery_data->id.'/
'; } } $contact_gallery_html .= '
'; $contact_gallery_html .= '
'; $contact_gallery_html .= '
タイトル
'; $contact_gallery_html .= '
'.$contact_gallery_data->name.'
'; $contact_gallery_html .= '
'; $contact_gallery_html .= '
'; $contact_gallery_html .= '
説明
'; $contact_gallery_html .= '
'.$contact_gallery_data->content.'
'; $contact_gallery_html .= '
'; $contact_html = $contact_gallery_html.$contact_html; } } //パラメータにリクルートIDがある場合 if(!empty($contact_recruit_id)){ $contact_recruit_data = $this->Recruits->find() ->where(['Recruits.id' => $contact_recruit_id]) ->where(['Recruits.company_id' => $company_id]) ->where(['Recruits.delete_flag' => 0]) ->first(); if(!empty($contact_recruit_data)){ $contact_company = $this->Companies->find() ->where(['Companies.id' => $company_id]) ->where(['Companies.delete_flag' => 0]) ->first(); $contact_recruit_query = $this->Newpages->find() ->where(['Newpages.company_id' => $company_id]) ->where(['Newpages.pagetype_id' => 10]) ->where(['Newpages.delete_flag' => 0]); //複数化 /*if(!empty($contact_recruit_data->recruit_kind)){ $contact_recruit_query->where(['Newpages.page_kind' => $contact_recruit_data->recruit_kind]); }else{ $contact_recruit_query->where(['OR' => [['Newpages.page_kind' => ''], ['Newpages.page_kind IS NULL']]]); }*/ $contact_recruit_page = $contact_recruit_query->first(); // $contact_recruit_html = ''; $contact_recruit_html .= ''; $contact_recruit_html .= ''; $contact_recruit_html .= ''; $contact_recruit_html .= '
'; $contact_recruit_html .= '
URL
'; if(!empty($contact_company->domain)){ $contact_recruit_html .= '
https://'.$contact_company->domain.'/'.$contact_recruit_page->slug.'/detail/'.$contact_recruit_data->id.'/
'; }else{ if(SV_KIND2 == 'IPP3_1'){ $contact_recruit_html .= '
https://'.$contact_company->subdomain.'.onerank-cms.com/'.$contact_recruit_page->slug.'/detail/'.$contact_recruit_data->id.'/
'; }elseif(SV_KIND2 == 'IPP3_2'){ $contact_recruit_html .= '
https://'.$contact_company->subdomain.'.onerank-cms-2.com/'.$contact_recruit_page->slug.'/detail/'.$contact_recruit_data->id.'/
'; }elseif(SV_KIND2 == 'IPP3_3'){ $contact_recruit_html .= '
https://'.$contact_company->subdomain.'.onerank-cms-3.com/'.$contact_recruit_page->slug.'/detail/'.$contact_recruit_data->id.'/
'; }elseif(SV_KIND2 == 'dev(AWS)'){ $contact_recruit_html .= '
https://'.$contact_company->subdomain.'.onerank-hybrid-dev.com/'.$contact_recruit_page->slug.'/detail/'.$contact_recruit_data->id.'/
'; }elseif(SV_KIND2 == 'dev2(AWS)'){ $contact_recruit_html .= '
https://'.$contact_company->subdomain.'.onerank-hybrid-dev2.com/'.$contact_recruit_page->slug.'/detail/'.$contact_recruit_data->id.'/
'; }elseif(SV_KIND2 == 'dev3(AWS)'){ $contact_recruit_html .= '
https://'.$contact_company->subdomain.'.onerank-hybrid-dev3.com/'.$contact_recruit_page->slug.'/detail/'.$contact_recruit_data->id.'/
'; } } $contact_recruit_html .= '
'; $contact_recruit_html .= '
'; $contact_recruit_html .= '
タイトル
'; $contact_recruit_html .= '
'.$contact_recruit_data->title.'
'; $contact_recruit_html .= '
'; $contact_recruit_html .= '
'; $contact_recruit_html .= '
説明
'; $contact_recruit_html .= '
'.$contact_recruit_data->content.'
'; $contact_recruit_html .= '
'; $contact_html = $contact_recruit_html.$contact_html; } } $html = str_replace($contact_loop[0], $contact_html, $html); $html = ''.$html; } } //Staff if($newblock->blocktype == 'block_staff'){ $staff_html = ''; preg_match('/{staff_loop}(.*?){\/staff_loop}/s', $html, $staff_loop); preg_match('/{staff_category_loop}(.*?){\/staff_category_loop}/s', $html, $staff_category_loop); preg_match('/{staff_item_loop}(.*?){\/staff_item_loop}/s', $html, $staff_item_loop); //カテゴリーで分けて表示 if($contents['staff_display_format'] == 1){ foreach($loop_data['Staffs'] as $Staffs){ $tmp_staff_loop = $staff_loop[1]; // $staff_categories = $Staffs['StaffCategories']; //カテゴリ名の表示 if($contents['staff_category_display'] == 2 && !empty($staff_categories[0]['name'])){ // $tmp_staff_category = str_replace('{title}', $staff_categories[0]['name'], $staff_category_loop[1]); //カテゴリ別名が存在する場合 if($staff_categories[0]['abbr'] != ''){ $tmp_staff_category = str_replace('{subtitlearea}', '', $tmp_staff_category); $tmp_staff_category = str_replace('{/subtitlearea}', '', $tmp_staff_category); $tmp_staff_category = str_replace('{subtitle}', $staff_categories[0]['abbr'], $tmp_staff_category); }else{ $tmp_staff_category = preg_replace('/{subtitlearea}(.*?){\/subtitlearea}/s', '', $tmp_staff_category); } $staff_html .= $tmp_staff_category; }else{ $tmp_staff_loop = preg_replace('/{staff_category_loop}(.*?){\/staff_category_loop}/s', '', $tmp_staff_loop); } //ループ開始前にカテゴリ部分を削除 $tmp_staff_loop = str_replace($staff_category_loop[0], '', $tmp_staff_loop); //※※※暫定対応 $staff_html .= '
'; // $staffs = $Staffs['Staffs']; foreach($staffs as $staff){ $staff_item = ''; $staff_item = str_replace('{title}', $staff['name'], $staff_item_loop[1]); $staff_item = str_replace('{title}', $staff['name'], $staff_item); /*if($staff['content'] && $staff['content'] != ''){ $staff_item = str_replace('{content}', $staff['content'], $staff_item); }else{ $staff_item = str_replace('{content}', '', $staff_item); }*/ // if($staff['content_json'] != ''){ $staff_contents = json_decode($staff['content_json'], true); }else{ $staff_contents = ''; } // preg_match('/{staff_content_loop}(.*?){\/staff_content_loop}/s', $html, $staff_content_loop); $staff_content = ''; if(!empty($staff_contents)){ // foreach($staff_contents as $staff_content2){ $tmp_staff_content = ''; // if(!empty($staff_content2['name']) && !empty($staff_content2['content'])){ $tmp_staff_content = str_replace('{name}', $staff_content2['name'], $staff_content_loop[1]); //$tmp_staff_content = str_replace('{content}', nl2br($staff_content2['content']), $tmp_staff_content); if(preg_match( "/\/[a-z]*>/i", $staff_content2['content'])){ $tmp_staff_content = str_replace('{content}', $staff_content2['content'], $tmp_staff_content); }else{ $tmp_staff_content = str_replace('{content}', nl2br($staff_content2['content']), $tmp_staff_content); } } $staff_content .= $tmp_staff_content; } } $staff_item = str_replace($staff_content_loop[0], $staff_content, $staff_item); //別名が存在する場合 if($staff['abbr'] != ''){ $staff_item = str_replace('{subtitlearea}', '', $staff_item); $staff_item = str_replace('{/subtitlearea}', '', $staff_item); $staff_item = str_replace('{subtitle}', $staff['abbr'], $staff_item); }else{ $staff_item = preg_replace('/{subtitlearea}(.*?){\/subtitlearea}/s', '', $staff_item); } //画像が存在する場合 if($staff['image'] != ''){ $staff_item = str_replace('{staff_item_image_area}', '', $staff_item); $staff_item = str_replace('{/staff_item_image_area}', '', $staff_item); $staff_item = str_replace('{image}', $img_dir_path.$staff['image'], $staff_item); }else{ $staff_item = preg_replace('/{staff_item_image_area}(.*?){\/staff_item_image_area}/s', '', $staff_item); } // $staff_html .= $staff_item; } //※※※暫定対応 $staff_html .= '
'; } $html = str_replace($staff_loop[0], $staff_html, $html); //一括表示 }else{ //カテゴリ表示部分の削除 $html = str_replace($staff_category_loop[0], '', $html); $html = str_replace('{staff_loop}', '', $html); $html = str_replace('{/staff_loop}', '', $html); // foreach($loop_data['Staffs'] as $Staffs){ $staff_item = ''; $staff_item = str_replace('{title}', $Staffs['name'], $staff_item_loop[1]); $staff_item = str_replace('{title}', $Staffs['name'], $staff_item); /*if($Staffs['content'] && $Staffs['content'] != ''){ $staff_item = str_replace('{content}', $Staffs['content'], $staff_item); }else{ $staff_item = str_replace('{content}', '', $staff_item); }*/ // if($Staffs['content_json'] != ''){ $staff_contents = json_decode($Staffs['content_json'], true); }else{ $staff_contents = ''; } // preg_match('/{staff_content_loop}(.*?){\/staff_content_loop}/s', $html, $staff_content_loop); $staff_content = ''; if(!empty($staff_contents)){ // foreach($staff_contents as $staff_content2){ $tmp_staff_content = ''; // if(!empty($staff_content2['name']) && !empty($staff_content2['content'])){ $tmp_staff_content = str_replace('{name}', $staff_content2['name'], $staff_content_loop[1]); //$tmp_staff_content = str_replace('{content}', nl2br($staff_content2['content']), $tmp_staff_content); if(preg_match( "/\/[a-z]*>/i", $staff_content2['content'])){ $tmp_staff_content = str_replace('{content}', $staff_content2['content'], $tmp_staff_content); }else{ $tmp_staff_content = str_replace('{content}', nl2br($staff_content2['content']), $tmp_staff_content); } } $staff_content .= $tmp_staff_content; } } $staff_item = str_replace($staff_content_loop[0], $staff_content, $staff_item); //別名が存在する場合 if($Staffs['abbr'] != ''){ $staff_item = str_replace('{subtitlearea}', '', $staff_item); $staff_item = str_replace('{/subtitlearea}', '', $staff_item); $staff_item = str_replace('{subtitle}', $Staffs['abbr'], $staff_item); }else{ $staff_item = preg_replace('/{subtitlearea}(.*?){\/subtitlearea}/s', '', $staff_item); } //画像が存在する場合 if($Staffs['image'] != ''){ $staff_item = str_replace('{staff_item_image_area}', '', $staff_item); $staff_item = str_replace('{/staff_item_image_area}', '', $staff_item); $staff_item = str_replace('{image}', $img_dir_path.$Staffs['image'], $staff_item); }else{ $staff_item = preg_replace('/{staff_item_image_area}(.*?){\/staff_item_image_area}/s', '', $staff_item); } // $staff_html .= $staff_item; } $html = str_replace($staff_item_loop[0], $staff_html, $html); } } //Question if($newblock->blocktype == 'block_question'){ $question_html = ''; preg_match('/{question_loop}(.*?){\/question_loop}/s', $html, $question_loop); preg_match('/{question_category_loop}(.*?){\/question_category_loop}/s', $html, $question_category_loop); preg_match('/{question_item_loop}(.*?){\/question_item_loop}/s', $html, $question_item_loop); // foreach($loop_data['Questions'] as $Questions){ $tmp_question_loop = $question_loop[1]; // $question_categories = $Questions['QuestionCategories']; //カテゴリ名の表示 if($contents['question_category_display'] == 2){ // if(!empty($question_categories)){ // $tmp_question_category = str_replace('{title}', $question_categories[0]['name'], $question_category_loop[1]); //カテゴリ別名が存在する場合 if($question_categories[0]['abbr'] != ''){ $tmp_question_category = str_replace('{question_category_subtitlearea}', '', $tmp_question_category); $tmp_question_category = str_replace('{/question_category_subtitlearea}', '', $tmp_question_category); $tmp_question_category = str_replace('{subtitle}', $question_categories[0]['abbr'], $tmp_question_category); }else{ $tmp_question_category = preg_replace('/{question_category_subtitlearea}(.*?){\/question_category_subtitlearea}/s', '', $tmp_question_category); } //カテゴリ説明が存在する場合 if($question_categories[0]['content'] != ''){ $tmp_question_category = str_replace('{question_category_content_area}', '', $tmp_question_category); $tmp_question_category = str_replace('{/question_category_content_area}', '', $tmp_question_category); $tmp_question_category = str_replace('{content}', nl2br($question_categories[0]['content']), $tmp_question_category); }else{ $tmp_question_category = preg_replace('/{question_category_content_area}(.*?){\/question_category_content_area}/s', '', $tmp_question_category); } $question_html .= $tmp_question_category; //ループ開始前にカテゴリ部分を削除 $tmp_question_loop = str_replace($question_category_loop[0], '', $tmp_question_loop); } }else{ $tmp_question_loop = preg_replace('/{question_category_loop}(.*?){\/question_category_loop}/s', '', $tmp_question_loop); } //※※※暫定対応 $question_html .= '
'; // $questions = $Questions['Questions']; foreach($questions as $question){ $question_item = ''; $question_item = str_replace('{question}', nl2br($question['question_content']), $question_item_loop[1]); $question_item = str_replace('{answer}', nl2br($question['answer_content']), $question_item); // $question_html .= $question_item; } //※※※暫定対応 $question_html .= '
'; } $html = str_replace($question_loop[0], $question_html, $html); } //Blog if($newblock->blocktype == 'block_blog' || $newblock->blocktype == 'block_blog2' || $newblock->blocktype == 'block_blog3' || $newblock->blocktype == 'block_blog4' || $newblock->blocktype == 'block_blog5'){ $blog_html = ''; preg_match('/{blog_loop}(.*?){\/blog_loop}/s', $html, $blog_loop); $tmp_slug = $loop_data['Blogs'][0]['ParentBlogs']->slug_plus; $blog_others = json_decode($loop_data['Blogs'][0]['ParentBlogs']->others, true); // foreach($loop_data['Blogs'] as $Blogs){ $tmp_blog_loop = $blog_loop[1]; // preg_match('/{blog_item_loop}(.*?){\/blog_item_loop}/s', $html, $blog_item_loop); // $blogs = $Blogs['Blogs']; if(!empty($blogs)){ foreach($blogs as $blog){ $blog_item = ''; $images = ''; $images = json_decode($blog['images'], true); $blog_item = str_replace('{slug}', $tmp_slug.'detail/'.$blog['slug'].'/', $blog_item_loop[1]); if(isset($blog_others['other5']) && $blog_others['other5'] == 1){ $blog_item = str_replace('{date}', '', $blog_item); }else{ $blog_item = str_replace('{date}', substr($blog['release_date'], 0, 10), $blog_item); } $blog_item = str_replace('{title}', $blog['name'], $blog_item); // if($contents['pattern01'] == 8 || $contents['pattern01'] == 9){ $ameblo_content = ''; //$ameblo_content = mb_strimwidth(strip_tags($blog['html']), 0, 60, '…', 'UTF-8'); $ameblo_content = mb_strimwidth($blog['ameblo_content'], 0, 60, '…', 'UTF-8'); $blog_item = str_replace('{content}', $ameblo_content, $blog_item); }else{ $blog_item = str_replace('

{content}

', '', $blog_item); } //category if($cms_version >= 2){ $blog_item = str_replace('{category_div}', '
', $blog_item); $blog_item = str_replace('{/category_div}', '
', $blog_item); if($contents['pattern01'] == 10){ }else{ if($contents['category_flag'] == 2){ //blogs[j].blog_categories if($blog['blog_categories'] && $blog['blog_categories'] != ''){ $tmp_category_list = ''; $tmp_category_list .= '
    '; foreach($blog['blog_categories'] as $category_data){ $tmp_category_list .= '
  1. '.$category_data['name'].'
  2. '; } $tmp_category_list .= '
'; } $blog_item = str_replace('{category_area}', $tmp_category_list, $blog_item); }else{ $blog_item = str_replace('{category_area}', '', $blog_item); } } }else{ $blog_item = str_replace('{category_area}', '', $blog_item); $blog_item = str_replace('{category_div}', '', $blog_item); $blog_item = str_replace('{/category_div}', '', $blog_item); } // $blog_item = str_replace('{datearea}', '', $blog_item); $blog_item = str_replace('{/datearea}', '', $blog_item); if($contents['pattern01'] == 4 || $contents['pattern01'] == 5 || $contents['pattern01'] == 6 || $contents['pattern01'] == 7 || $contents['pattern01'] == 8 || $contents['pattern01'] == 9 || $contents['pattern01'] == 10 || $contents['pattern01'] == 13 || $contents['pattern01'] == 14){ $blog_item = str_replace('{imagearea}', '', $blog_item); $blog_item = str_replace('{/imagearea}', '', $blog_item); if($images['eyecatch_image'] && $images['eyecatch_image'] != 'no_image.jpg'){ $blog_item = str_replace('{image}', $img_dir_path.$images['eyecatch_image'], $blog_item); $blog_item = str_replace('{noimg}', '', $blog_item); $blog_item = str_replace('{no_img}', '', $blog_item); }else if($images['image01']){ $blog_item = str_replace('{image}', $img_dir_path.$images['image01'], $blog_item); $blog_item = str_replace('{noimg}', '', $blog_item); $blog_item = str_replace('{no_img}', '', $blog_item); }else if($images['other_image']){ $blog_item = str_replace('{image}', $img_dir_path.$images['other_image'], $blog_item); $blog_item = str_replace('{noimg}', '', $blog_item); $blog_item = str_replace('{no_img}', '', $blog_item); }elseif(!empty($logo_image)){ $blog_item = str_replace('{image}', $img_dir_path.$logo_image, $blog_item); $blog_item = str_replace('{noimg}', ' class="noimg"', $blog_item); $blog_item = str_replace('{no_img}', ' class="no_img"', $blog_item); }else{ $blog_item = str_replace('{image}', '/common/public_image/no_image.jpg', $blog_item); $blog_item = str_replace('{noimg}', '', $blog_item); $blog_item = str_replace('{no_img}', '', $blog_item); } $blog_item = str_replace('{alt}', $blog['name'], $blog_item); }else{ $blog_item = str_replace('{noimg}', '', $blog_item); $blog_item = str_replace('{no_img}', '', $blog_item); $blog_item = preg_replace('/{imagearea}(.*?){\/imagearea}/s', '', $blog_item); } // $blog_html .= $blog_item; } }else{ $blog_html .= '

対象の記事はございません

'; } //※※※暫定対応 //$blog_html .= ''; } $html = str_replace($blog_loop[0], $blog_html, $html); //※※※暫定対応 $html = str_replace($blog_item_loop[0], '', $html); // if($contents['pattern01'] == 2){ $html = str_replace('{pattern01}', $contents['pattern01'], $html); }else{ $html = str_replace('{pattern01}', 1, $html); } if($contents['pattern01'] == 3){ $html = str_replace('{pattern02}', ' add_design2', $html); }else if($contents['pattern01'] == 4 || $contents['pattern01'] == 5){ $html = str_replace('{pattern02}', ' add_design3', $html); }else if($contents['pattern01'] == 6 || $contents['pattern01'] == 7){ $html = str_replace('{pattern02}', ' add_design4', $html); }else if($contents['pattern01'] == 8){ $html = str_replace('{pattern02}', ' add_design5', $html); }else if($contents['pattern01'] == 9){ $html = str_replace('{pattern02}', ' add_design6', $html); }else if($contents['pattern01'] == 10){ $html = str_replace('{pattern02}', ' add_design10', $html); }else if($contents['pattern01'] == 11){ $html = str_replace('{pattern02}', ' add_design11', $html); }else if($contents['pattern01'] == 12){ $html = str_replace('{pattern02}', ' add_design12', $html); }else if($contents['pattern01'] == 13){ $html = str_replace('{pattern02}', ' add_design13', $html); }else if($contents['pattern01'] == 14){ $html = str_replace('{pattern02}', ' add_design14', $html); }else{ $html = str_replace('{pattern02}', '', $html); } } //Cca if($newblock->blocktype == 'block_cca'){ $cca_html = ''; preg_match('/{cca_loop}(.*?){\/cca_loop}/s', $html, $cca_loop); $tmp_slug = $loop_data['Ccas'][0]['ParentCcas']->slug_plus; $cca_others = json_decode($loop_data['Ccas'][0]['ParentCcas']->others, true); $pagenation = $this->pagenation_data($page_num, $loop_data['Ccas'][0]['TotalResults'], 12); // foreach($loop_data['Ccas'] as $Ccas){ $tmp_cca_loop = $cca_loop[1]; // preg_match('/{cca_item_loop}(.*?){\/cca_item_loop}/s', $html, $cca_item_loop); // $ccas = $Ccas['Ccas']; if(!empty($ccas)){ foreach($ccas as $cca){ $cca_item = ''; $images = ''; $images = json_decode($cca['images'], true); $cca_item = str_replace('{slug}', $tmp_slug.$cca['slug'].'/', $cca_item_loop[1]); //if(isset($cca_others['other5']) && $cca_others['other5'] == 1){ //}else{ //$cca_item = str_replace('{date}', substr($cca['release_date'], 0, 10), $cca_item); //} $cca_item = str_replace('{title}', $cca['title'], $cca_item); // $description = ''; //$ameblo_content = mb_strimwidth(strip_tags($blog['html']), 0, 60, '…', 'UTF-8'); $description = mb_strimwidth($cca['description'], 0, 400, '…', 'UTF-8'); $cca_item = str_replace('

{content}

', $description, $cca_item); $cca_item = str_replace('{imagearea}', '', $cca_item); $cca_item = str_replace('{/imagearea}', '', $cca_item); if($images['eyecatch_image'] && $images['eyecatch_image'] != 'no_image.jpg'){ $cca_item = str_replace('{image}', $img_dir_path.$images['eyecatch_image'], $cca_item); $cca_item = str_replace('{noimg}', '', $cca_item); $cca_item = str_replace('{no_img}', '', $cca_item); }else if($images['image01']){ $cca_item = str_replace('{image}', $img_dir_path.$images['image01'], $cca_item); $cca_item = str_replace('{noimg}', '', $cca_item); $cca_item = str_replace('{no_img}', '', $cca_item); }else if($images['other_image']){ $cca_item = str_replace('{image}', $img_dir_path.$images['other_image'], $cca_item); $cca_item = str_replace('{noimg}', '', $cca_item); $cca_item = str_replace('{no_img}', '', $cca_item); }elseif(!empty($logo_image)){ $cca_item = str_replace('{image}', $img_dir_path.$logo_image, $cca_item); $cca_item = str_replace('{noimg}', ' class="noimg"', $cca_item); $cca_item = str_replace('{no_img}', ' class="no_img"', $cca_item); }else{ $cca_item = str_replace('{image}', '/common/public_image/no_image.jpg', $cca_item); $cca_item = str_replace('{noimg}', '', $cca_item); $cca_item = str_replace('{no_img}', '', $cca_item); } $cca_item = str_replace('{alt}', $cca['name'], $cca_item); // $cca_html .= $cca_item; } }else{ $cca_html .= '

対象の記事はございません

'; } //※※※暫定対応 //$cca_html .= ''; } //$pagenation $pager_html = ''; $data['pagenation'] = $pagenation; $view = $this->viewBuilder()->build(); $pager_html = $view->element('Pagenation',['data' => $data, 'pagenation_url' => $tmp_slug]); $html = str_replace('{pagenation}', $pager_html, $html); $html = str_replace($cca_loop[0], $cca_html, $html); //※※※暫定対応 $html = str_replace($cca_item_loop[0], '', $html); } //Column if($newblock->blocktype == 'block_column' || $newblock->blocktype == 'block_column2' || $newblock->blocktype == 'block_column3' || $newblock->blocktype == 'block_column4' || $newblock->blocktype == 'block_column5'){ $column_html = ''; preg_match('/{column_loop}(.*?){\/column_loop}/s', $html, $column_loop); $tmp_slug = $loop_data['Columns'][0]['ParentColumns']->slug_plus; $column_others = json_decode($loop_data['Columns'][0]['ParentColumns']->others, true); // foreach($loop_data['Columns'] as $columns){ $tmp_column_loop = $column_loop[1]; // preg_match('/{column_item_loop}(.*?){\/column_item_loop}/s', $html, $column_item_loop); // $columns = $columns['Columns']; if(!empty($columns)){ foreach($columns as $column){ $column_item = ''; $images = ''; $images = json_decode($column['images'], true); $column_item = str_replace('{slug}', $tmp_slug.'detail/'.$column['slug'].'/', $column_item_loop[1]); if(isset($column_others['other5']) && $column_others['other5'] == 1){ $column_item = str_replace('{date}', '', $column_item); }else{ $column_item = str_replace('{date}', substr($column['release_date'], 0, 10), $column_item); } $column_item = str_replace('{title}', $column['name'], $column_item); // if($contents['pattern01'] == 8 || $contents['pattern01'] == 9){ $ameblo_content = ''; //$ameblo_content = mb_strimwidth(strip_tags($column['html']), 0, 60, '…', 'UTF-8'); $ameblo_content = mb_strimwidth($column['ameblo_content'], 0, 60, '…', 'UTF-8'); $column_item = str_replace('{content}', $ameblo_content, $column_item); }else{ $column_item = str_replace('

{content}

', '', $column_item); } // $column_item = str_replace('{datearea}', '', $column_item); $column_item = str_replace('{/datearea}', '', $column_item); if($contents['pattern01'] == 4 || $contents['pattern01'] == 5 || $contents['pattern01'] == 6 || $contents['pattern01'] == 7 || $contents['pattern01'] == 8 || $contents['pattern01'] == 9 || $contents['pattern01'] == 10 || $contents['pattern01'] == 13 || $contents['pattern01'] == 14){ $column_item = str_replace('{imagearea}', '', $column_item); $column_item = str_replace('{/imagearea}', '', $column_item); if($images['eyecatch_image'] && $images['eyecatch_image'] != 'no_image.jpg'){ $column_item = str_replace('{image}', $img_dir_path.$images['eyecatch_image'], $column_item); $column_item = str_replace('{noimg}', '', $column_item); $column_item = str_replace('{no_img}', '', $column_item); }else if($images['image01']){ $column_item = str_replace('{image}', $img_dir_path.$images['image01'], $column_item); $column_item = str_replace('{noimg}', '', $column_item); $column_item = str_replace('{no_img}', '', $column_item); }else if($images['other_image']){ $column_item = str_replace('{image}', $img_dir_path.$images['other_image'], $column_item); $column_item = str_replace('{noimg}', '', $column_item); $column_item = str_replace('{no_img}', '', $column_item); }elseif(!empty($logo_image)){ $column_item = str_replace('{image}', $img_dir_path.$logo_image, $column_item); $column_item = str_replace('{noimg}', ' class="noimg"', $column_item); $column_item = str_replace('{no_img}', ' class="no_img"', $column_item); }else{ $column_item = str_replace('{image}', '/common/public_image/no_image.jpg', $column_item); $column_item = str_replace('{noimg}', '', $column_item); $column_item = str_replace('{no_img}', '', $column_item); } $column_item = str_replace('{alt}', $column['name'], $column_item); }else{ $column_item = str_replace('{noimg}', '', $column_item); $column_item = str_replace('{no_img}', '', $column_item); $column_item = preg_replace('/{imagearea}(.*?){\/imagearea}/s', '', $column_item); } // $column_html .= $column_item; } }else{ $column_html .= '

対象の記事はございません

'; } //※※※暫定対応 //$column_html .= ''; } $html = str_replace($column_loop[0], $column_html, $html); //※※※暫定対応 $html = str_replace($column_item_loop[0], '', $html); // if($contents['pattern01'] == 2){ $html = str_replace('{pattern01}', $contents['pattern01'], $html); }else{ $html = str_replace('{pattern01}', 1, $html); } if($contents['pattern01'] == 3){ $html = str_replace('{pattern02}', ' add_design2', $html); }else if($contents['pattern01'] == 4 || $contents['pattern01'] == 5){ $html = str_replace('{pattern02}', ' add_design3', $html); }else if($contents['pattern01'] == 6 || $contents['pattern01'] == 7){ $html = str_replace('{pattern02}', ' add_design4', $html); }else if($contents['pattern01'] == 8){ $html = str_replace('{pattern02}', ' add_design5', $html); }else if($contents['pattern01'] == 9){ $html = str_replace('{pattern02}', ' add_design6', $html); }else if($contents['pattern01'] == 10){ $html = str_replace('{pattern02}', ' add_design10', $html); }else if($contents['pattern01'] == 11){ $html = str_replace('{pattern02}', ' add_design11', $html); }else if($contents['pattern01'] == 12){ $html = str_replace('{pattern02}', ' add_design12', $html); }else if($contents['pattern01'] == 13){ $html = str_replace('{pattern02}', ' add_design13', $html); }else if($contents['pattern01'] == 14){ $html = str_replace('{pattern02}', ' add_design14', $html); }else{ $html = str_replace('{pattern02}', '', $html); } } //Multigallery if($newblock->blocktype == 'block_multigallery' || $newblock->blocktype == 'block_multigallery2' || $newblock->blocktype == 'block_multigallery3' || $newblock->blocktype == 'block_multigallery4' || $newblock->blocktype == 'block_multigallery5'){ $multigallery_html = ''; preg_match('/{multigallery_loop}(.*?){\/multigallery_loop}/s', $html, $multigallery_loop); $tmp_slug = $loop_data['Multigalleries'][0]['ParentMultigalleries']->slug_plus; $multigallery_others = json_decode($loop_data['Multigalleries'][0]['ParentMultigalleries']->others, true); // foreach($loop_data['Multigalleries'] as $Multigalleries){ $tmp_multigallery_loop = $multigallery_loop[1]; // preg_match('/{multigallery_item_loop}(.*?){\/multigallery_item_loop}/s', $html, $multigallery_item_loop); // $multigalleries = $Multigalleries['Multigalleries']; $parent = $Multigalleries['ParentMultigalleries']; if($Multigalleries['ParentMultigalleries'][0]['others'] && $Multigalleries['ParentMultigalleries'][0]['others'] != ''){ $others = json_decode($Multigalleries['ParentMultigalleries'][0]['others'], true); } if(!empty($multigalleries)){ foreach($multigalleries as $multigallery){ $multigallery_item = ''; $images = ''; $images = json_decode($multigallery['images'], true); $multigallery_item = str_replace('{slug}', $tmp_slug.'detail/'.$multigallery['slug'].'/', $multigallery_item_loop[1]); if(isset($multigallery_others['other5']) && $multigallery_others['other5'] == 1){ $multigallery_item = str_replace('{date}', '', $multigallery_item); }else{ $multigallery_item = str_replace('{date}', substr($multigallery['release_date'], 0, 10), $multigallery_item); } $multigallery_item = str_replace('{title}', $multigallery['name'], $multigallery_item); // if($contents['pattern01'] == 8 || $contents['pattern01'] == 9){ if(isset($multigallery_others['excerpt_flag']) && $multigallery_others['excerpt_flag'] == 2){ $ameblo_content = ''; //$ameblo_content = mb_strimwidth(strip_tags($multigallery['html']), 0, 60, '…', 'UTF-8'); //$ameblo_content = mb_strimwidth($multigallery['excerpt'], 0, 60, '…', 'UTF-8'); $ameblo_content = nl2br($multigallery['excerpt']); $multigallery_item = str_replace('{content}', $ameblo_content, $multigallery_item); }elseif(isset($multigallery_others['excerpt_flag']) && $multigallery_others['excerpt_flag'] == 1){ $multigallery_item = str_replace('

{content}

', '', $multigallery_item); }else{ $ameblo_content = ''; //$ameblo_content = mb_strimwidth(strip_tags($multigallery['html']), 0, 60, '…', 'UTF-8'); $ameblo_content = mb_strimwidth($multigallery['ameblo_content'], 0, 60, '…', 'UTF-8'); $multigallery_item = str_replace('{content}', $ameblo_content, $multigallery_item); } }else{ $multigallery_item = str_replace('

{content}

', '', $multigallery_item); } //category if($cms_version >= 2){ $multigallery_item = str_replace('{category_div}', '
', $multigallery_item); $multigallery_item = str_replace('{/category_div}', '
', $multigallery_item); if($contents['pattern01'] == 10){ }else{ if($contents['category_flag'] == 2){ //multigallery[j].multigallery_categories if($multigallery['multigallery_categories'] && $multigallery['multigallery_categories'] != ''){ $tmp_category_list = ''; $tmp_category_list .= '
    '; foreach($multigallery['multigallery_categories'] as $category_data){ $tmp_category_list .= '
  1. '.$category_data['name'].'
  2. '; } $tmp_category_list .= '
'; } $multigallery_item = str_replace('{category_area}', $tmp_category_list, $multigallery_item); }else{ $multigallery_item = str_replace('{category_area}', '', $multigallery_item); } } }else{ $multigallery_item = str_replace('{category_area}', '', $multigallery_item); $multigallery_item = str_replace('{category_div}', '', $multigallery_item); $multigallery_item = str_replace('{/category_div}', '', $multigallery_item); } // $multigallery_item = str_replace('{datearea}', '', $multigallery_item); $multigallery_item = str_replace('{/datearea}', '', $multigallery_item); if($contents['pattern01'] == 4 || $contents['pattern01'] == 5 || $contents['pattern01'] == 6 || $contents['pattern01'] == 7 || $contents['pattern01'] == 8 || $contents['pattern01'] == 9 || $contents['pattern01'] == 10 || $contents['pattern01'] == 13 || $contents['pattern01'] == 14){ $multigallery_item = str_replace('{imagearea}', '', $multigallery_item); $multigallery_item = str_replace('{/imagearea}', '', $multigallery_item); if($images['eyecatch_image'] && $images['eyecatch_image'] != 'no_image.jpg'){ $multigallery_item = str_replace('{image}', $img_dir_path.$images['eyecatch_image'], $multigallery_item); $multigallery_item = str_replace('{noimg}', '', $multigallery_item); $multigallery_item = str_replace('{no_img}', '', $multigallery_item); }else if($images['image01']){ $multigallery_item = str_replace('{image}', $img_dir_path.$images['image01'], $multigallery_item); $multigallery_item = str_replace('{noimg}', '', $multigallery_item); $multigallery_item = str_replace('{no_img}', '', $multigallery_item); }else if($images['other_image']){ $multigallery_item = str_replace('{image}', $img_dir_path.$images['other_image'], $multigallery_item); $multigallery_item = str_replace('{noimg}', '', $multigallery_item); $multigallery_item = str_replace('{no_img}', '', $multigallery_item); }elseif(!empty($logo_image)){ $multigallery_item = str_replace('{image}', $img_dir_path.$logo_image, $multigallery_item); $multigallery_item = str_replace('{noimg}', ' class="noimg"', $multigallery_item); $multigallery_item = str_replace('{no_img}', ' class="no_img"', $multigallery_item); }else{ $multigallery_item = str_replace('{image}', '/common/public_image/no_image.jpg', $multigallery_item); $multigallery_item = str_replace('{noimg}', '', $multigallery_item); $multigallery_item = str_replace('{no_img}', '', $multigallery_item); } $multigallery_item = str_replace('{alt}', $multigallery['name'], $multigallery_item); }else{ $multigallery_item = str_replace('{noimg}', '', $multigallery_item); $multigallery_item = str_replace('{no_img}', '', $multigallery_item); $multigallery_item = preg_replace('/{imagearea}(.*?){\/imagearea}/s', '', $multigallery_item); } // $multigallery_html .= $multigallery_item; } }else{ $multigallery_html .= '

対象の記事はございません

'; } //※※※暫定対応 //$multigallery_html .= ''; } $html = str_replace($multigallery_loop[0], $multigallery_html, $html); //※※※暫定対応 $html = str_replace($multigallery_item_loop[0], '', $html); // if($contents['pattern01'] == 2){ $html = str_replace('{pattern01}', $contents['pattern01'], $html); }else{ $html = str_replace('{pattern01}', 1, $html); } if($contents['pattern01'] == 3){ $html = str_replace('{pattern02}', ' add_design2', $html); }else if($contents['pattern01'] == 4 || $contents['pattern01'] == 5){ $html = str_replace('{pattern02}', ' add_design3', $html); }else if($contents['pattern01'] == 6 || $contents['pattern01'] == 7){ $html = str_replace('{pattern02}', ' add_design4', $html); }else if($contents['pattern01'] == 8){ $html = str_replace('{pattern02}', ' add_design5', $html); }else if($contents['pattern01'] == 9){ $html = str_replace('{pattern02}', ' add_design6', $html); }else if($contents['pattern01'] == 10){ $html = str_replace('{pattern02}', ' add_design10', $html); }else if($contents['pattern01'] == 11){ $html = str_replace('{pattern02}', ' add_design11', $html); }else if($contents['pattern01'] == 12){ $html = str_replace('{pattern02}', ' add_design12', $html); }else if($contents['pattern01'] == 13){ $html = str_replace('{pattern02}', ' add_design13', $html); }else if($contents['pattern01'] == 14){ $html = str_replace('{pattern02}', ' add_design14', $html); }else{ $html = str_replace('{pattern02}', '', $html); } } //News if($newblock->blocktype == 'block_news' || $newblock->blocktype == 'block_news2' || $newblock->blocktype == 'block_news3' || $newblock->blocktype == 'block_news4' || $newblock->blocktype == 'block_news5'){ $news_html = ''; preg_match('/{news_loop}(.*?){\/news_loop}/s', $html, $news_loop); // $tmp_slug = $loop_data['News'][0]['ParentNews']->slug_plus; $news_others = json_decode($loop_data['News'][0]['ParentNews']->others, true); foreach($loop_data['News'] as $News){ $tmp_news_loop = $news_loop[1]; // preg_match('/{news_item_loop}(.*?){\/news_item_loop}/s', $html, $news_item_loop); // $newss = $News['News']; if(!empty($newss)){ foreach($newss as $news){ $news_item = ''; $images = ''; $images = json_decode($news['images'], true); $news_item = str_replace('{slug}', $tmp_slug.'detail/'.$news['slug'].'/', $news_item_loop[1]); //$news_item = str_replace('{date}', substr($news['release_date'], 0, 10), $news_item); if(isset($news_others['other5']) && $news_others['other5'] == 1){ $news_item = str_replace('{date}', '', $news_item); }else{ $news_item = str_replace('{date}', substr($news['release_date'], 0, 10), $news_item); } $news_item = str_replace('{title}', $news['name'], $news_item); //category if($cms_version >= 2){ $news_item = str_replace('{category_div}', '
', $news_item); $news_item = str_replace('{/category_div}', '
', $news_item); if($contents['pattern01'] == 10){ //news_item = news_item.replace('{category_area}', ''); }else{ if($contents['category_flag'] == 2){ //news[j].news_categories if($news['news_categories'] && $news['news_categories'] != ''){ $tmp_category_list = ''; $tmp_category_list .= '
    '; foreach($news['news_categories'] as $category_data){ $tmp_category_list .= '
  1. '.$category_data['name'].'
  2. '; } $tmp_category_list .= '
'; } $news_item = str_replace('{category_area}', $tmp_category_list, $news_item); }else{ $news_item = str_replace('{category_area}', '', $news_item); } } }else{ $news_item = str_replace('{category_area}', '', $news_item); $news_item = str_replace('{category_div}', '', $news_item); $news_item = str_replace('{/category_div}', '', $news_item); } // $news_item = str_replace('{datearea}', '', $news_item); $news_item = str_replace('{/datearea}', '', $news_item); if($contents['pattern01'] == 4 || $contents['pattern01'] == 5 || $contents['pattern01'] == 6 || $contents['pattern01'] == 7 || $contents['pattern01'] == 8 || $contents['pattern01'] == 9 || $contents['pattern01'] == 10 || $contents['pattern01'] == 13 || $contents['pattern01'] == 14){ $news_item = str_replace('{imagearea}', '', $news_item); $news_item = str_replace('{/imagearea}', '', $news_item); if($images['eyecatch_image'] && $images['eyecatch_image'] != 'no_image.jpg'){ $news_item = str_replace('{image}', $img_dir_path.$images['eyecatch_image'], $news_item); $news_item = str_replace('{noimg}', '', $news_item); $news_item = str_replace('{no_img}', '', $news_item); }else if($images['image01']){ $news_item = str_replace('{image}', $img_dir_path.$images['image01'], $news_item); $news_item = str_replace('{noimg}', '', $news_item); $news_item = str_replace('{no_img}', '', $news_item); }else if($images['other_image']){ $news_item = str_replace('{image}', $img_dir_path.$images['other_image'], $news_item); $news_item = str_replace('{noimg}', '', $news_item); $news_item = str_replace('{no_img}', '', $news_item); }elseif(!empty($logo_image)){ $news_item = str_replace('{image}', $img_dir_path.$logo_image, $news_item); $news_item = str_replace('{noimg}', ' class="noimg"', $news_item); $news_item = str_replace('{no_img}', ' class="no_img"', $news_item); }else{ $news_item = str_replace('{image}', '/common/public_image/no_image.jpg', $news_item); $news_item = str_replace('{noimg}', '', $news_item); $news_item = str_replace('{no_img}', '', $news_item); } $news_item = str_replace('{alt}', $news['name'], $news_item); }else{ $news_item = preg_replace('/{imagearea}(.*?){\/imagearea}/s', '', $news_item); } // $news_html .= $news_item; } }else{ $news_html .= '

対象の記事はございません

'; } //※※※暫定対応 //$news_html .= ''; } $html = str_replace($news_loop[0], $news_html, $html); //※※※暫定対応 $html = str_replace($news_item_loop[0], '', $html); // if($contents['pattern01'] == 2){ $html = str_replace('{pattern01}', $contents['pattern01'], $html); }else{ $html = str_replace('{pattern01}', 1, $html); } if($contents['pattern01'] == 3){ $html = str_replace('{pattern02}', ' add_design2', $html); }else if($contents['pattern01'] == 4 || $contents['pattern01'] == 5){ $html = str_replace('{pattern02}', ' add_design3', $html); }else if($contents['pattern01'] == 6 || $contents['pattern01'] == 7){ $html = str_replace('{pattern02}', ' add_design4', $html); }else if($contents['pattern01'] == 8){ $html = str_replace('{pattern02}', ' add_design5', $html); }else if($contents['pattern01'] == 9){ $html = str_replace('{pattern02}', ' add_design6', $html); }else if($contents['pattern01'] == 10){ $html = str_replace('{pattern02}', ' add_design10', $html); }else if($contents['pattern01'] == 11){ $html = str_replace('{pattern02}', ' add_design11', $html); }else if($contents['pattern01'] == 12){ $html = str_replace('{pattern02}', ' add_design12', $html); }else if($contents['pattern01'] == 13){ $html = str_replace('{pattern02}', ' add_design13', $html); }else if($contents['pattern01'] == 14){ $html = str_replace('{pattern02}', ' add_design14', $html); }else{ $html = str_replace('{pattern02}', '', $html); } } //History if($newblock->blocktype == 'block_history'){ $history_html = ''; preg_match('/{history_loop}(.*?){\/history_loop}/s', $html, $history_loop); // foreach($loop_data['Historys'] as $Historys){ $tmp_history_loop = $history_loop[1]; // preg_match('/{history_item_loop}(.*?){\/history_item_loop}/s', $html, $history_item_loop); // $historys = $Historys['Historys']; foreach($historys as $history){ $history_item = ''; //URLの正規化 $slug_plus = ''; if($history['pagetype_id'] == 1){ $slug_plus = '/'; }elseif($history['pagetype_id'] == 4 || $history['pagetype_id'] == 6){ if($history['pagetype_id'] == 4){ $slug_plus = '/'.$history['slug'].'/'; }elseif($history['pagetype_id'] == 6){ $slug_plus = '/detail/'.$history['slug'].'/'; } //親ページがあるか確認 $history_parent01 = $this->Newpages->find() ->where(['Newpages.id' => $history['id']]) ->where(['Newpages.company_id' => $company_id]) ->where(['Newpages.display_flag' => 1]) ->where(['Newpages.delete_flag' => 0]) ->first(); if(!empty($history_parent01->parent_id) && $history_parent01->parent_id != 0){ //親ページがあるか確認 $history_parent02 = $this->Newpages->find() ->where(['Newpages.id' => $history_parent01->parent_id]) ->where(['Newpages.company_id' => $company_id]) ->where(['Newpages.display_flag' => 1]) ->where(['Newpages.delete_flag' => 0]) ->first(); $slug_plus = '/'.$history_parent02->slug.$slug_plus; if(!empty($history_parent02->parent_id) && $history_parent02->parent_id != 0){ //親ページがあるか確認 $history_parent03 = $this->Newpages->find() ->where(['Newpages.id' => $history_parent02->parent_id]) ->where(['Newpages.company_id' => $company_id]) ->where(['Newpages.display_flag' => 1]) ->where(['Newpages.delete_flag' => 0]) ->first(); $slug_plus = '/'.$history_parent03->slug.$slug_plus; } } }else{ $slug_plus = '/'.$history['slug'].'/'; } // //$history_item = str_replace('{slug}', $history['slug'], $history_item_loop[1]); $history_item = str_replace('{slug}', $slug_plus, $history_item_loop[1]); $history_item = str_replace('{date}', substr($history['modified'], 0, 10), $history_item); if($history['created'] == $history['modified']){ $title = $history['name'].'を公開しました'; }else{ $title = $history['name'].'を更新しました'; } $history_item = str_replace('{title}', $title, $history_item); // $history_html .= $history_item; } //※※※暫定対応 //$history_html .= ''; } $html = str_replace($history_loop[0], $history_html, $html); //※※※暫定対応 $html = str_replace($history_item_loop[0], '', $html); // if($contents['pattern01'] == 2){ $html = str_replace('{pattern01}', $contents['pattern01'], $html); }else{ $html = str_replace('{pattern01}', 1, $html); } if($contents['pattern02'] == 3){ $html = str_replace('{pattern02}', ' add_design2', $html); }else if($contents['pattern01'] == 4 || $contents['pattern01'] == 5){ $html = str_replace('{pattern02}', ' add_design3', $html); }else if($contents['pattern01'] == 6 || $contents['pattern01'] == 7){ $html = str_replace('{pattern02}', ' add_design4', $html); }else if($contents['pattern01'] == 8){ $html = str_replace('{pattern02}', ' add_design5', $html); }else if($contents['pattern01'] == 9){ $html = str_replace('{pattern02}', ' add_design6', $html); }else{ $html = str_replace('{pattern02}', '', $html); } } //Shop if($newblock->blocktype == 'block_shop'){ $shop_html = ''; preg_match('/{shop_loop}(.*?){\/shop_loop}/s', $html, $shop_loop); $shop_data = $loop_data['Shops'][0]; $tmp_shop_loop = $shop_loop[1]; // if($contents['pattern01'] == 1 || $contents['pattern01'] == 3 || $contents['pattern01'] == 4 || $contents['pattern01'] == 5){ // if($contents['pattern01'] == 1){ if(!empty($shop_data['image'])){ $tmp_shop_loop = str_replace('{imagearea}', '', $tmp_shop_loop); $tmp_shop_loop = str_replace('{/imagearea}', '', $tmp_shop_loop); $tmp_shop_loop = str_replace('{image}', $img_dir_path.$shop_data['image'], $tmp_shop_loop); }else{ $tmp_shop_loop = preg_replace('/{imagearea}(.*?){\/imagearea}/s', '', $tmp_shop_loop); } }elseif($contents['pattern01'] == 3 || $contents['pattern01'] == 4 || $contents['pattern01'] == 5){ $tmp_shop_loop = str_replace('{imagearea}', '', $tmp_shop_loop); $tmp_shop_loop = str_replace('{/imagearea}', '', $tmp_shop_loop); //署名用画像対応 if(isset($shop_data['signature_image']) && !empty($shop_data['signature_image'])){ $tmp_shop_loop = str_replace('{image}', '/common/upload_data/'.$subdomain.'/image/'.$shop_data['signature_image'], $tmp_shop_loop); }else{ $tmp_shop_loop = str_replace('{image}', '/common/upload_data/'.$subdomain.'/image/'.$logo_image, $tmp_shop_loop); } } // if($shop_data['map_flag'] == 1){ if($shop_data['address_type'] == 1){ $address = $shop_data['g_prefecture'].$shop_data['g_city'].$shop_data['g_town']; $tmp_shop_loop = str_replace('{maparea}', '', $tmp_shop_loop); $tmp_shop_loop = str_replace('{/maparea}', '', $tmp_shop_loop); $tmp_shop_loop = str_replace('{mapurl}', 'https://www.google.com/maps/embed/v1/place?key=AIzaSyAAJMHu_2xgfRLagpx77TaqPQroo2DYz9Y&q='.urlencode($address), $tmp_shop_loop); $tmp_shop_loop = str_replace('{mapaddress1}', urlencode($address), $tmp_shop_loop); }else{ if($shop_data['address1'] != ''){ $tmp_shop_loop = str_replace('{maparea}', '', $tmp_shop_loop); $tmp_shop_loop = str_replace('{/maparea}', '', $tmp_shop_loop); $tmp_shop_loop = str_replace('{mapurl}', 'https://www.google.com/maps/embed/v1/place?key=AIzaSyAAJMHu_2xgfRLagpx77TaqPQroo2DYz9Y&q='.urlencode($shop_data['address1']), $tmp_shop_loop); $tmp_shop_loop = str_replace('{mapaddress1}', urlencode($shop_data['address1']), $tmp_shop_loop); } } //$tmp_shop_loop = str_replace('{address1}', urlencode($shop_data['address1']), $tmp_shop_loop); //URLから直接入力 }elseif($shop_data['map_flag'] == 2){ $tmp_shop_loop = str_replace('{maparea}', '', $tmp_shop_loop); $tmp_shop_loop = str_replace('{/maparea}', '', $tmp_shop_loop); $tmp_shop_loop = str_replace('{mapurl}', $shop_data['g_map_url'], $tmp_shop_loop); $tmp_shop_loop = str_replace('{mapaddress1}', $shop_data['g_map_url'], $tmp_shop_loop); }else{ $tmp_shop_loop = preg_replace('/{maparea}(.*?){\/maparea}/s', '', $tmp_shop_loop); } }elseif($contents['pattern01'] == 2){ $html = str_replace('{pattern02}', ' add_design2', $html); //if(!empty($shop_data['image']) || ($shop_data['map_flag'] == 1 && $shop_data['address1'] != '')){ if(!empty($shop_data['image']) || ($shop_data['map_flag'] >= 1)){ $tmp_shop_loop = str_replace('{imagemaparea}', '', $tmp_shop_loop); $tmp_shop_loop = str_replace('{/imagemaparea}', '', $tmp_shop_loop); // if(!empty($shop_data['image'])){ $tmp_shop_loop = str_replace('{imagearea}', '', $tmp_shop_loop); $tmp_shop_loop = str_replace('{/imagearea}', '', $tmp_shop_loop); $tmp_shop_loop = str_replace('{image}', $img_dir_path.$shop_data['image'], $tmp_shop_loop); }else{ $tmp_shop_loop = preg_replace('/{imagearea}(.*?){\/imagearea}/s', '', $tmp_shop_loop); } // if($shop_data['map_flag'] == 1){ if($shop_data['address_type'] == 1){ $address = $shop_data['g_prefecture'].$shop_data['g_city'].$shop_data['g_town']; $tmp_shop_loop = str_replace('{maparea}', '', $tmp_shop_loop); $tmp_shop_loop = str_replace('{/maparea}', '', $tmp_shop_loop); $tmp_shop_loop = str_replace('{mapurl}', 'https://www.google.com/maps/embed/v1/place?key=AIzaSyAAJMHu_2xgfRLagpx77TaqPQroo2DYz9Y&q='.urlencode($address), $tmp_shop_loop); $tmp_shop_loop = str_replace('{mapaddress1}', urlencode($address), $tmp_shop_loop); }else{ if($shop_data['address1'] != ''){ $tmp_shop_loop = str_replace('{maparea}', '', $tmp_shop_loop); $tmp_shop_loop = str_replace('{/maparea}', '', $tmp_shop_loop); $tmp_shop_loop = str_replace('{mapurl}', 'https://www.google.com/maps/embed/v1/place?key=AIzaSyAAJMHu_2xgfRLagpx77TaqPQroo2DYz9Y&q='.urlencode($shop_data['address1']), $tmp_shop_loop); $tmp_shop_loop = str_replace('{mapaddress1}', urlencode($shop_data['address1']), $tmp_shop_loop); } } //$tmp_shop_loop = str_replace('{address1}', urlencode($shop_data['address1']), $tmp_shop_loop); //URLから直接入力 }elseif($shop_data['map_flag'] == 2){ $tmp_shop_loop = str_replace('{maparea}', '', $tmp_shop_loop); $tmp_shop_loop = str_replace('{/maparea}', '', $tmp_shop_loop); $tmp_shop_loop = str_replace('{mapurl}', $shop_data['g_map_url'], $tmp_shop_loop); $tmp_shop_loop = str_replace('{mapaddress1}', $shop_data['g_map_url'], $tmp_shop_loop); }else{ $tmp_shop_loop = preg_replace('/{maparea}(.*?){\/maparea}/s', '', $tmp_shop_loop); } }else{ $tmp_shop_loop = preg_replace('/{imagemaparea}(.*?){\/imagemaparea}/s', '', $tmp_shop_loop); } } //$tmp_shop_loop = str_replace('{image}', $img_dir_path.$shop_data['image'], $tmp_shop_loop); $tmp_shop_loop = str_replace('{name}', $shop_data['name'], $tmp_shop_loop); //$tmp_shop_loop = str_replace('{name}', $shop_data['name'], $tmp_shop_loop); $tmp_shop_loop = str_replace('{image_alt_name}', str_replace(array('
', '
', '
'), '', $shop_data['name']), $tmp_shop_loop); // if($shop_data['tel'] != ''){ $tmp_shop_loop = str_replace('{telarea}', '', $tmp_shop_loop); $tmp_shop_loop = str_replace('{/telarea}', '', $tmp_shop_loop); $tmp_shop_loop = str_replace('{tel}', $shop_data['tel'], $tmp_shop_loop); if($shop_data['tel_sup'] && $shop_data['tel_sup'] != ''){ $tmp_shop_loop = str_replace('{tel_sup}', '

'.nl2br($shop_data['tel_sup']).'

', $tmp_shop_loop); }else{ $tmp_shop_loop = str_replace('{tel_sup}', '', $tmp_shop_loop); } }else{ $tmp_shop_loop = preg_replace('/{telarea}(.*?){\/telarea}/s', '', $tmp_shop_loop); } // if($shop_data['fax'] != ''){ $tmp_shop_loop = str_replace('{faxarea}', '', $tmp_shop_loop); $tmp_shop_loop = str_replace('{/faxarea}', '', $tmp_shop_loop); $tmp_shop_loop = str_replace('{fax}', $shop_data['fax'], $tmp_shop_loop); }else{ $tmp_shop_loop = preg_replace('/{faxarea}(.*?){\/faxarea}/s', '', $tmp_shop_loop); } // if($shop_data['address_type'] == 1){ if($shop_data['zip3'] != '' || $shop_data['zip4'] != '' || $shop_data['g_prefecture'] != '' || $shop_data['g_city'] != '' || $shop_data['g_town'] != ''){ if($shop_data['zip3'] == '' && $shop_data['zip4'] == ''){ $tmp_shop_loop = preg_replace('/{ziparea}(.*?){\/ziparea}/s', '', $tmp_shop_loop); }else{ $tmp_shop_loop = str_replace('{ziparea}', '', $tmp_shop_loop); $tmp_shop_loop = str_replace('{/ziparea}', '', $tmp_shop_loop); $tmp_shop_loop = str_replace('{zip3}', $shop_data['zip3'], $tmp_shop_loop); $tmp_shop_loop = str_replace('{zip4}', $shop_data['zip4'], $tmp_shop_loop); } $tmp_shop_loop = str_replace('{addressarea}', '', $tmp_shop_loop); $tmp_shop_loop = str_replace('{/addressarea}', '', $tmp_shop_loop); $tmp_shop_loop = str_replace('{address1}', $shop_data['g_prefecture'].$shop_data['g_city'].$shop_data['g_town'], $tmp_shop_loop); $tmp_shop_loop = str_replace('{address2}', ' '.$shop_data['g_address'], $tmp_shop_loop); }else{ $tmp_shop_loop = preg_replace('/{addressarea}(.*?){\/addressarea}/s', '', $tmp_shop_loop); } }else{ if($shop_data['zip3'] != '' || $shop_data['zip4'] != '' || $shop_data['address1'] != '' || $shop_data['address2'] != ''){ if($shop_data['zip3'] == '' && $shop_data['zip4'] == ''){ $tmp_shop_loop = preg_replace('/{ziparea}(.*?){\/ziparea}/s', '', $tmp_shop_loop); }else{ $tmp_shop_loop = str_replace('{ziparea}', '', $tmp_shop_loop); $tmp_shop_loop = str_replace('{/ziparea}', '', $tmp_shop_loop); $tmp_shop_loop = str_replace('{zip3}', $shop_data['zip3'], $tmp_shop_loop); $tmp_shop_loop = str_replace('{zip4}', $shop_data['zip4'], $tmp_shop_loop); } $tmp_shop_loop = str_replace('{addressarea}', '', $tmp_shop_loop); $tmp_shop_loop = str_replace('{/addressarea}', '', $tmp_shop_loop); $tmp_shop_loop = str_replace('{address1}', $shop_data['address1'], $tmp_shop_loop); $tmp_shop_loop = str_replace('{address2}', $shop_data['address2'], $tmp_shop_loop); }else{ $tmp_shop_loop = preg_replace('/{addressarea}(.*?){\/addressarea}/s', '', $tmp_shop_loop); } } // if($shop_data['content_json'] != ''){ $shop_contents = json_decode($shop_data['content_json'], true); }else{ $shop_contents = ''; } // if($contents['pattern01'] == 1 || $contents['pattern01'] == 2){ preg_match('/{shop_item_loop}(.*?){\/shop_item_loop}/s', $html, $shop_item_loop); $shop_item = ''; if(!empty($shop_contents)){ // foreach($shop_contents as $shop_content){ $tmp_shop_item = ''; // if(!empty($shop_content['name']) && !empty($shop_content['content'])){ $tmp_shop_item = str_replace('{title}', $shop_content['name'], $shop_item_loop[1]); $tmp_shop_item = str_replace('{content}', nl2br($shop_content['content']), $tmp_shop_item); } $shop_item .= $tmp_shop_item; } } }else{ $tmp_shop_loop = str_replace('{comment}', nl2br($shop_data['comment']), $tmp_shop_loop); } $tmp_shop_loop = str_replace($shop_item_loop[0], $shop_item, $tmp_shop_loop); $html = str_replace($shop_loop[0], $tmp_shop_loop, $html); } //Area エリア if($newblock->blocktype == 'block_area'){ $area_html = ''; preg_match('/{area_loop}(.*?){\/area_loop}/s', $html, $area_loops); $area_loop = $area_loops[1]; $area_data = $loop_data['Areas'][0]; if($area_data['place_mode'] == 1){ $area_loop = str_replace('{place_area}', '', $area_loop); $area_loop = str_replace('{/place_area}', '', $area_loop); $place_data = ''; $place_array = json_decode($area_data['place_json'], true); foreach($place_array as $key=>$val){ $place_data .= '
'.$val.'
'; } //$area_loop = str_replace($area_loop[0], $place_data, $html); $area_loop = preg_replace('/{place_loop}(.*?){\/place_loop}/s', $place_data, $area_loop); }else{ $area_loop = preg_replace('/{place_area}(.*?){\/place_area}/s', '', $area_loop); } if($area_data['train_mode'] == 1){ $area_loop = str_replace('{train_area}', '', $area_loop); $area_loop = str_replace('{/train_area}', '', $area_loop); $train_data = ''; $train_array = json_decode($area_data['train_json'], true); foreach($train_array as $key=>$val){ $train_data .= '
'.$val.'駅
'; } //$area_loop = str_replace($area_loop[0], $train_data, $html); $area_loop = preg_replace('/{train_loop}(.*?){\/train_loop}/s', $train_data, $area_loop); }else{ $area_loop = preg_replace('/{train_area}(.*?){\/train_area}/s', '', $area_loop); } $html = str_replace($area_loops[0], $area_loop, $html); } //Conversions if($newblock->blocktype == 'block_cv'){ $cv_data = $loop_data['Conversions'][0]; $html = str_replace('{cv_loop}', '', $html); //キャッチコピー・導入文・説明文 if($$cv_data['tagline'] == '' && $cv_data['introduction'] == '' && $cv_data['description'] == ''){ $html = preg_replace('/{texts_area}(.*?){\/texts_area}/s', '', $html); }else{ $html = str_replace('{texts_area}', '', $html); $html = str_replace('{/texts_area}', '', $html); // if($cv_data['tagline'] == ''){ $html = preg_replace('/{tagline_area}(.*?){\/tagline_area}/s', '', $html); }else{ $html = str_replace('{tagline_area}', '', $html); $html = str_replace('{/tagline_area}', '', $html); $html = str_replace('{tagline}', $cv_data['tagline'], $html); } if($cv_data['introduction'] == ''){ $html = preg_replace('/{introduction_area}(.*?){\/introduction_area}/s', '', $html); }else{ $html = str_replace('{introduction_area}', '', $html); $html = str_replace('{/introduction_area}', '', $html); $html = str_replace('{introduction}', $cv_data['introduction'], $html); } if($cv_data['description'] == ''){ $html = preg_replace('/{description_area}(.*?){\/description_area}/s', '', $html); }else{ $html = str_replace('{description_area}', '', $html); $html = str_replace('{/description_area}', '', $html); $html = str_replace('{description}', $cv_data['description'], $html); } } //ボタン if($cv_data['type01'] == '0' && $cv_data['introduction'] == 'type02'){ $html = preg_replace('/{btns_area}(.*?){\/btns_area}/s', '', $html); }else{ $html = str_replace('{btns_area}', '', $html); $html = str_replace('{/btns_area}', '', $html); // if($cv_data['type01'] == '0'){ $html = preg_replace('/{btn1_area}(.*?){\/btn1_area}/s', '', $html); }else{ $html = str_replace('{btn1_area}', '', $html); $html = str_replace('{/btn1_area}', '', $html); $html = str_replace('{button_lavel01}', $cv_data['button_lavel01'], $html); $html = str_replace('{comment01}', $cv_data['comment01'], $html); $html = str_replace('{block_cv_btn1_txt}', $contents['block_cv_btn1_txt'], $html); $html = str_replace('{block_cv_btn1_bg}', $contents['block_cv_btn1_bg'], $html); $html = str_replace('{block_cv_btn1_border}', $contents['block_cv_btn1_border'], $html); } // if($cv_data['type02'] == '0'){ $html = preg_replace('/{btn2_area}(.*?){\/btn2_area}/s', '', $html); }else{ $html = str_replace('{btn2_area}', '', $html); $html = str_replace('{/btn2_area}', '', $html); $html = str_replace('{button_lavel02}', $cv_data['button_lavel02'], $html); $html = str_replace('{comment02}', $cv_data['comment02'], $html); $html = str_replace('{block_cv_btn2_txt}', $contents['block_cv_btn2_txt'], $html); $html = str_replace('{block_cv_btn2_bg}', $contents['block_cv_btn2_bg'], $html); $html = str_replace('{block_cv_btn2_border}', $contents['block_cv_btn2_border'], $html); } } dd($cv_data); //リンク if($cv_data['type01'] == '1'){ $html = str_replace('tel:{link_value01}', 'tel:'.$cv_data['link_value01'], $html); $html = str_replace('{link_value01}', 'tel:'.$cv_data['link_value01'], $html); }elseif($cv_data['type01'] == '3'){ $clean_id01 = ltrim(trim($cv_data['link_value01']), '@'); $line_url01 = 'https://line.me/R/ti/p/%40' . $clean_id01; $html = str_replace('tel:{link_value01}', $line_url01, $html); $html = str_replace('{link_value01}', $line_url01, $html); }else{ $html = str_replace('tel:{link_value01}', $cv_data['link_value01'], $html); $html = str_replace('{link_value01}', $cv_data['link_value01'], $html); } if($cv_data['type02'] == '1'){ $html = str_replace('tel:{link_value02}', 'tel:'.$cv_data['link_value02'], $html); $html = str_replace('{link_value02}', 'tel:'.$cv_data['link_value02'], $html); }elseif($cv_data['type02'] == '3'){ $clean_id02 = ltrim(trim($cv_data['link_value02']), '@'); $line_url02 = 'https://line.me/R/ti/p/%40' . $clean_id02; $html = str_replace('tel:{link_value02}', $line_url02, $html); $html = str_replace('{link_value02}', $line_url02, $html); }else{ $html = str_replace('tel:{link_value02}', $cv_data['link_value02'], $html); $html = str_replace('{link_value02}', $cv_data['link_value02'], $html); } } //Authors if($newblock->blocktype == 'block_author'){ $author_data = $loop_data['Authors'][0]; $html = str_replace('{author_loop}', '', $html); //image if($author_data['image'] == ''){ $html = preg_replace('/{image_area}(.*?){\/image_area}/s', '', $html); }else{ $html = str_replace('{image_area}', '', $html); $html = str_replace('{/image_area}', '', $html); $html = str_replace('{image}', $img_dir_path.$author_data['image'], $html); } //content01 if($author_data['title01'] == '' && $author_data['comment01']){ $html = preg_replace('/{content01_area}(.*?){\/content01_area}/s', '', $html); }else{ $html = str_replace('{content01_area}', '', $html); $html = str_replace('{/content01_area}', '', $html); if($author_data['title01'] == ''){ $html = preg_replace('/{title01_area}(.*?){\/title01_area}/s', '', $html); }else{ $html = str_replace('{title01_area}', '', $html); $html = str_replace('{/title01_area}', '', $html); $html = str_replace('{title01}', $author_data['title01'], $html); } if($author_data['comment01'] == ''){ $html = preg_replace('/{comment01_area}(.*?){\/comment01_area}/s', '', $html); }else{ $html = str_replace('{comment01_area}', '', $html); $html = str_replace('{/comment01_area}', '', $html); $html = str_replace('{comment01}', $author_data['comment01'], $html); } } //content02 if($author_data['title02'] == '' && $author_data['comment02']){ $html = preg_replace('/{content02_area}(.*?){\/content02_area}/s', '', $html); }else{ $html = str_replace('{content02_area}', '', $html); $html = str_replace('{/content02_area}', '', $html); if($author_data['title02'] == ''){ $html = preg_replace('/{title02_area}(.*?){\/title02_area}/s', '', $html); }else{ $html = str_replace('{title02_area}', '', $html); $html = str_replace('{/title02_area}', '', $html); $html = str_replace('{title02}', $author_data['title02'], $html); } if($author_data['comment02'] == ''){ $html = preg_replace('/{comment02_area}(.*?){\/comment02_area}/s', '', $html); }else{ $html = str_replace('{comment02_area}', '', $html); $html = str_replace('{/comment02_area}', '', $html); $html = str_replace('{comment02}', $author_data['comment02'], $html); } } //content03 if($author_data['title03'] == '' && $author_data['comment03']){ $html = preg_replace('/{content03_area}(.*?){\/content03_area}/s', '', $html); }else{ $html = str_replace('{content03_area}', '', $html); $html = str_replace('{/content03_area}', '', $html); if($author_data['title03'] == ''){ $html = preg_replace('/{title03_area}(.*?){\/title03_area}/s', '', $html); }else{ $html = str_replace('{title03_area}', '', $html); $html = str_replace('{/title03_area}', '', $html); $html = str_replace('{title03}', $author_data['title03'], $html); } if($author_data['comment03'] == ''){ $html = preg_replace('/{comment03_area}(.*?){\/comment03_area}/s', '', $html); }else{ $html = str_replace('{comment03_area}', '', $html); $html = str_replace('{/comment03_area}', '', $html); $html = str_replace('{comment03}', $author_data['comment03'], $html); } } //content04 if($author_data['title04'] == '' && $author_data['comment04']){ $html = preg_replace('/{content04_area}(.*?){\/content04_area}/s', '', $html); }else{ $html = str_replace('{content04_area}', '', $html); $html = str_replace('{/content04_area}', '', $html); if($author_data['title04'] == ''){ $html = preg_replace('/{title04_area}(.*?){\/title04_area}/s', '', $html); }else{ $html = str_replace('{title04_area}', '', $html); $html = str_replace('{/title04_area}', '', $html); $html = str_replace('{title04}', $author_data['title04'], $html); } if($author_data['comment04'] == ''){ $html = preg_replace('/{comment04_area}(.*?){\/comment04_area}/s', '', $html); }else{ $html = str_replace('{comment04_area}', '', $html); $html = str_replace('{/comment04_area}', '', $html); $html = str_replace('{comment04}', $author_data['comment04'], $html); } } } //Corporations if($newblock->blocktype == 'block_company'){ $company_data = $loop_data['Corporations'][0]; $html = str_replace('{corporation_loop}', '', $html); //image if($company_data['image'] == ''){ $html = preg_replace('/{image_area}(.*?){\/image_area}/s', '', $html); }else{ $html = str_replace('{image_area}', '', $html); $html = str_replace('{/image_area}', '', $html); $html = str_replace('{image}', $img_dir_path.$company_data['image'], $html); } // $html = str_replace('{header}', $company_data['header'], $html); $html = str_replace('{subheader01}', $company_data['subheader01'], $html); $html = str_replace('{content01}', $company_data['content01'], $html); $html = str_replace('{subheader02}', $company_data['subheader02'], $html); $html = str_replace('{content02}', $company_data['content02'], $html); $html = str_replace('{f_header}', $company_data['f_header'], $html); $html = str_replace('{f_content}', $company_data['f_content'], $html); $html = str_replace('{f_header01}', $company_data['f_header01'], $html); $html = str_replace('{f_content01}', $company_data['f_content01'], $html); $html = str_replace('{f_image01}', $img_dir_path.$company_data['f_image01'], $html); $html = str_replace('{f_header02}', $company_data['f_header02'], $html); $html = str_replace('{f_content02}', $company_data['f_content02'], $html); $html = str_replace('{f_image02}', $img_dir_path.$company_data['f_image02'], $html); $html = str_replace('{f_header03}', $company_data['f_header03'], $html); $html = str_replace('{f_content03}', $company_data['f_content03'], $html); $html = str_replace('{f_image03}', $img_dir_path.$company_data['f_image03'], $html); $html = str_replace('{f_header04}', $company_data['f_header04'], $html); $html = str_replace('{f_content04}', $company_data['f_content04'], $html); $html = str_replace('{f_image04}', $img_dir_path.$company_data['f_image04'], $html); $html = str_replace('{f_header05}', $company_data['f_header05'], $html); $html = str_replace('{f_content05}', $company_data['f_content05'], $html); $html = str_replace('{f_image05}', $img_dir_path.$company_data['f_image05'], $html); $html = str_replace('{t_header}', $company_data['t_header'], $html); $html = str_replace('{t_content}', $company_data['t_content'], $html); $html = str_replace('{c_header}', $company_data['c_header'], $html); $html = str_replace('{c_content}', $company_data['c_content'], $html); $html = str_replace('{c_image}', $img_dir_path.$company_data['c_image'], $html); } //Comparison if($newblock->blocktype == 'block_comparison'){ $comparison_html = ''; preg_match('/{comparison_loop}(.*?){\/comparison_loop}/s', $html, $comparison_loop); preg_match('/{comparison_category_loop}(.*?){\/comparison_category_loop}/s', $html, $comparison_category_loop); preg_match('/{comparison_item_loop}(.*?){\/comparison_item_loop}/s', $html, $comparison_item_loop); //カテゴリーで分けて表示 if($contents['comparison_display_format'] == 1){ foreach($loop_data['Comparisons'] as $Comparisons){ $tmp_comparison_loop = $comparison_loop[1]; // $comparison_categories = $Comparisons['ComparisonCategories'][0]; //カテゴリ名の表示 if($contents['comparison_category_display'] == 2){ // $tmp_comparison_category = str_replace('{title}', $comparison_categories['name'], $comparison_category_loop[1]); //カテゴリ別名が存在する場合 if($comparison_categories['abbr'] != ''){ $tmp_comparison_category = str_replace('{subtitlearea}', '', $tmp_comparison_category); $tmp_comparison_category = str_replace('{/subtitlearea}', '', $tmp_comparison_category); $tmp_comparison_category = str_replace('{subtitle}', $comparison_categories['abbr'], $tmp_comparison_category); }else{ $tmp_comparison_category = preg_replace('/{subtitlearea}(.*?){\/subtitlearea}/s', '', $tmp_comparison_category); } // $comparison_html .= $tmp_comparison_category; //ループ開始前にカテゴリ部分を削除 $tmp_comparison_loop = str_replace($comparison_category_loop[0], '', $tmp_comparison_loop); }else{ $tmp_comparison_loop = preg_replace('/{comparison_category_loop}(.*?){\/comparison_category_loop}/s', '', $tmp_comparison_loop); } //※※※暫定対応 $comparison_html .= '
'; // $comparisons = $Comparisons['Comparisons']; foreach($comparisons as $comparison){ $comparison_item = ''; $comparison_item = str_replace('{after_image}', $img_dir_path.$comparison['after_image'], $comparison_item_loop[1]); //$comparison_item = str_replace('{after_image}', $img_dir_path.$comparison['after_image'], $comparison_item); $comparison_item = str_replace('{before_image}', $img_dir_path.$comparison['before_image'], $comparison_item); //$comparison_item = str_replace('{before_image}', $img_dir_path.$comparison['before_image'], $comparison_item); $comparison_item = str_replace('{title}', $comparison['name'], $comparison_item); //カテゴリ別名が存在する場合 if($comparison['content'] != ''){ $comparison_item = str_replace('{contentarea}', '', $comparison_item); $comparison_item = str_replace('{/contentarea}', '', $comparison_item); $comparison_item = str_replace('{content}', nl2br($comparison['content']), $comparison_item); }else{ $comparison_item = preg_replace('/{contentarea}(.*?){\/contentarea}/s', '', $comparison_item); } // $comparison_html .= $comparison_item; } //※※※暫定対応 $comparison_html .= '
'; } $html = str_replace($comparison_loop[0], $comparison_html, $html); //一括表示 }else if($contents['comparison_display_format'] == 2){ //カテゴリ表示部分の削除 $html = str_replace($comparison_category_loop[0], '', $html); $html = str_replace('{comparison_loop}', '', $html); $html = str_replace('{/comparison_loop}', '', $html); // foreach($loop_data['Comparisons'] as $Comparisons){ $comparison_item = ''; $comparison_item = str_replace('{after_image}', $img_dir_path.$Comparisons['after_image'], $comparison_item_loop[1]); //$comparison_item = str_replace('{after_image}', $img_dir_path.$Comparisons['after_image'], $comparison_item); $comparison_item = str_replace('{before_image}', $img_dir_path.$Comparisons['before_image'], $comparison_item); //$comparison_item = str_replace('{before_image}', $img_dir_path.$Comparisons['before_image'], $comparison_item); $comparison_item = str_replace('{title}', $Comparisons['name'], $comparison_item); //カテゴリ別名が存在する場合 if($Comparisons['content'] != ''){ $comparison_item = str_replace('{contentarea}', '', $comparison_item); $comparison_item = str_replace('{/contentarea}', '', $comparison_item); $comparison_item = str_replace('{content}', nl2br($Comparisons['content']), $comparison_item); }else{ $comparison_item = preg_replace('/{contentarea}(.*?){\/contentarea}/s', '', $comparison_item); } // $comparison_html .= $comparison_item; } $html = str_replace($comparison_item_loop[0], $comparison_html, $html); //一件表示 }else if($contents['comparison_display_format'] == 3){ //カテゴリ表示部分の削除 $html = str_replace($comparison_category_loop[0], '', $html); $html = str_replace('{comparison_loop}', '', $html); $html = str_replace('{/comparison_loop}', '', $html); // foreach($loop_data['Comparisons'] as $Comparisons){ $comparison_item = ''; $comparison_item = str_replace('{after_image}', $img_dir_path.$Comparisons['after_image'], $comparison_item_loop[1]); //$comparison_item = str_replace('{after_image}', $img_dir_path.$Comparisons['after_image'], $comparison_item); $comparison_item = str_replace('{before_image}', $img_dir_path.$Comparisons['before_image'], $comparison_item); //$comparison_item = str_replace('{before_image}', $img_dir_path.$Comparisons['before_image'], $comparison_item); $comparison_item = str_replace('{title}', $Comparisons['name'], $comparison_item); //カテゴリ別名が存在する場合 if($Comparisons['content'] != ''){ $comparison_item = str_replace('{contentarea}', '', $comparison_item); $comparison_item = str_replace('{/contentarea}', '', $comparison_item); $comparison_item = str_replace('{content}', nl2br($Comparisons['content']), $comparison_item); }else{ $comparison_item = preg_replace('/{contentarea}(.*?){\/contentarea}/s', '', $comparison_item); } // $comparison_html .= $comparison_item; } $html = str_replace($comparison_item_loop[0], $comparison_html, $html); } //システム自動出力一覧用の暫定処理 if($contents['link_type'] == 3){ $html = str_replace('{button_link}', '/comparison_archive/all/', $html); } } //Youtubelist if($newblock->blocktype == 'block_youtubelist'){ $youtubelist_html = ''; preg_match('/{youtubelist_loop}(.*?){\/youtubelist_loop}/s', $html, $youtubelist_loop); // foreach($loop_data['Youtubelist'] as $Youtubelist){ $youtubelist_item = ''; $youtubelist_item = str_replace('{youtubelist_id}', $Youtubelist['youtubelist_id'], $youtubelist_loop[1]); $youtubelist_item = str_replace('{youtubelist_title}', $Youtubelist['youtubelist_title'], $youtubelist_item); $youtubelist_item = str_replace('{youtubelist_date}', $Youtubelist['youtubelist_date'], $youtubelist_item); $youtubelist_item = str_replace('{youtubelist_description}', $Youtubelist['youtubelist_description'], $youtubelist_item); // $youtubelist_html .= $youtubelist_item; } $html = str_replace($youtubelist_loop[0], $youtubelist_html, $html); } //口コミ if($newblock->blocktype == 'block_comments'){ $comments_html = ''; preg_match('/{comments_item_loop}(.*?){\/comments_item_loop}/s', $html, $comments_loop); // foreach($loop_data['Comments'] as $comment){ $comments_item = ''; $comments_item = str_replace('{gmb_reviewer_profile_photo_url}', $comment['gmb_reviewer_profile_photo_url'], $comments_loop[1]); $comments_item = str_replace('{gmb_reviewer_display_name}', $comment['gmb_reviewer_display_name'], $comments_item); $comments_item = str_replace('{gmb_star_rating}', $comment['gmb_star_rating'], $comments_item); $comments_item = str_replace('{post_datetime}', $comment['post_datetime'], $comments_item); $comments_item = str_replace('{review_comment}', nl2br($comment['review_comment']), $comments_item); // if(!empty($comment['reply'])){ $comments_item = str_replace('{reply_area}', '', $comments_item); $comments_item = str_replace('{/reply_area}', '', $comments_item); $comments_item = str_replace('{reply}', nl2br($comment['reply']), $comments_item); }else{ $comments_item = preg_replace('/{reply_area}(.*?){\/reply_area}/s', '', $comments_item); } // $comments_html .= $comments_item; } if($contents['button_flag'] == 1){ $html = str_replace('{button_area}', '', $html); $html = str_replace('{/button_area}', '', $html); }else{ $html = preg_replace('/{button_area}(.*?){\/button_area}/s', '', $html); } $html = str_replace($comments_loop[0], $comments_html, $html); } //アンケート if($newblock->blocktype == 'block_enquete'){ $html = ''; $script_data = ''; $script_data .= ''."\n"; // $enquete_num = count($enquete_detail_datas); // //$script_data .= ''."\n"; $html = $script_data.$html; $html .= ' '; $html .= ''."\n"; $html .= ''."\n"; $html .= ''."\n"; } //ベースHTML内のコンテンツ置換 preg_match_all('/\{pattern..\}/', $html, $pattern_list); preg_match_all('/\{headline..\}/', $html, $headline_list); preg_match_all('/\{subheadline..\}/', $html, $subheadline_list); preg_match_all('/\{otherheadline..\}/', $html, $otherheadline_list); preg_match_all('/\{text..\}/', $html, $text_list); preg_match_all('/\{t_align..\}/', $html, $t_align_list); preg_match_all('/\{image..\}/', $html, $image_list); preg_match_all('/\{alt..\}/', $html, $alt_list); preg_match_all('/\{link..\}/', $html, $link_list); preg_match_all('/\{other..\}/', $html, $other_list); preg_match_all('/\{headline_target..\}/', $html, $headline_target_list); preg_match_all('/\{subheadline_target..\}/', $html, $subheadline_target_list); preg_match_all('/\{otherheadline_target..\}/', $html, $otherheadline_target_list); preg_match_all('/\{image_target..\}/', $html, $image_target_list); preg_match_all('/\{span_target..\}/', $html, $span_target_list); // $html = str_replace('{without}', '', $html); // if(!empty($pattern_list[0])){ foreach($pattern_list[0] as $key=>$val){ $comp_pattern = str_replace('{', '', $val); $comp_pattern = str_replace('}', '', $comp_pattern); if($contents[$comp_pattern]){ $html = str_replace($val, $contents[$comp_pattern], $html); }else{ $html = str_replace($val, '', $html); } } } //$css_directの処理 $css_direct = ''; // if(!empty($contents['css_bg'])){ if(!empty($contents['bgimage'])){ //※※※パブリックイメージの暫定対応 if($contents['bgimage'] == 'no_image.jpg'){ $img_dir_path2 = '/common/public_image/'; }else{ $img_dir_path2 = $img_dir_path; } $img_url = $img_dir_path2.$contents['bgimage']; }else{ //$img_url = '/common/upload_data/'.$subdomain.'/image/no_image.jpg'; $img_url = ''; } if($contents['css_bg'] == 1){ $css_direct .= 'background-image: url('.$img_url.'); '; $html = str_replace('{parallax_class}', '', $html); $html = str_replace('{parallax_tag}', '', $html); }else if($contents['css_bg'] == 2){ $html = str_replace('{parallax_tag}', '
', $html); $html = str_replace('{parallax_class}', ' parallax', $html); }else{ $html = str_replace('{parallax_class}', '', $html); $html = str_replace('{parallax_tag}', '', $html); } }else{ $html = str_replace('{parallax_class}', '', $html); $html = str_replace('{parallax_tag}', '', $html); } if(!empty($contents['css_bgr'])){ //しない if($contents['css_bgr'] == 1){ $css_direct .= 'background-repeat: no-repeat; '; //する }else if($contents['css_bgr'] == 2){ $css_direct .= 'background-repeat: repeat; '; //縦方向 }else if($contents['css_bgr'] == 3){ $css_direct .= 'background-repeat: repeat-y; '; //横方向 }else if($contents['css_bgr'] == 4){ $css_direct .= 'background-repeat: repeat-x; '; } } if(!empty($contents['css_bgp'])){ //左上 if($contents['css_bgp'] == 1){ $css_direct .= 'background-position: 0 0; '; //左中央 }else if($contents['css_bgp'] == 2){ $css_direct .= 'background-position: 0 50%; '; //左下 }else if($contents['css_bgp'] == 3){ $css_direct .= 'background-position: 0 100%; '; //中央上 }else if($contents['css_bgp'] == 4){ $css_direct .= 'background-position: 50% 0; '; //中央 }else if($contents['css_bgp'] == 5){ $css_direct .= 'background-position: 50% 50%; '; //中央下 }else if($contents['css_bgp'] == 6){ $css_direct .= 'background-position: 50% 100%; '; //右上 }else if($contents['css_bgp'] == 7){ $css_direct .= 'background-position: 100% 0; '; //右中央 }else if($contents['css_bgp'] == 8){ $css_direct .= 'background-position: 100% 50%; '; //右下 }else if($contents['css_bgp'] == 9){ $css_direct .= 'background-position: 100% 100%; '; } } if(!empty($contents['css_bgs'])){ //そのまま if($contents['css_bgs'] == 1){ $css_direct .= 'background-size: auto; '; //覆う }else if($contents['css_bgs'] == 2){ $css_direct .= 'background-size: cover; '; //フィット }else if($contents['css_bgs'] == 3){ $css_direct .= 'background-size: contain; '; } } if(!empty($contents['color'])){ $css_direct .= 'color: '.$contents['color'].'; '; } if(!empty($contents['bgcolor'])){ $css_direct .= 'background-color: '.$contents['bgcolor'].'; '; } // if(!empty($css_direct)){ $html = str_replace('{css_direct}', ' style="'.$css_direct.'"', $html); }else{ $html = str_replace('{css_direct}', '', $html); } //共通処理・見出し if($contents['headline_flag'] && $contents['headline_flag'] != 1){ $html = str_replace('{headlinearea}', '', $html); $html = str_replace('{/headlinearea}', '', $html); //※※※ $html = str_replace('{h_align}', $contents['h_align'], $html); $html = str_replace('{pattern}', $contents['pattern'], $html); $html = str_replace('{headline}', $contents['headline'], $html); if($contents['headline_flag'] && $contents['headline_flag'] == 2 && isset($contents['subheadline']) && !empty($contents['subheadline'])){ $html = str_replace('{subheadlinearea}', '', $html); $html = str_replace('{/subheadlinearea}', '', $html); $html = str_replace('{subheadline}', $contents['subheadline'], $html); }else{ $html = preg_replace('/{subheadlinearea}(.*?){\/subheadlinearea}/s', '', $html); } if($contents['headline_flag'] && $contents['headline_flag'] == 2 && isset($contents['otherheadline']) && !empty($contents['otherheadline'])){ $html = str_replace('{otherheadlinearea}', '', $html); $html = str_replace('{/otherheadlinearea}', '', $html); $html = str_replace('{otherheadline}', $contents['otherheadline'], $html); }else{ $html = preg_replace('/{otherheadlinearea}(.*?){\/otherheadlinearea}/s', '', $html); } }else{ $html = preg_replace('/{headlinearea}(.*?){\/headlinearea}/s', '', $html); } //共通処理・ボタン if(isset($contents['button_label']) && $contents['button_label'] != ''){ $html = str_replace('{buttonarea}', '', $html); $html = str_replace('{/buttonarea}', '', $html); //※※※ $html = str_replace('{button_link}', $contents['button_link'], $html); $html = str_replace('{button_label}', $contents['button_label'], $html); }else{ $html = preg_replace('/{buttonarea}(.*?){\/buttonarea}/s', '', $html); } // if(isset($contents['link_target02']) && $contents['link_target02'] == 1){ $html = str_replace('{link_target02}', ' target="_blank"', $html); }else{ $html = str_replace('{link_target02}', '', $html); } // if(!empty($headline_list[0])){ foreach($headline_list[0] as $key=>$val){ $comp_headline = str_replace('{', '', $val); $comp_headline = str_replace('}', '', $comp_headline); if(isset($contents[$comp_headline])){ $html = str_replace($val, $contents[$comp_headline], $html); }else{ $html = str_replace($val, '', $html); } } } if(!empty($subheadline_list[0])){ foreach($subheadline_list[0] as $key=>$val){ $comp_subheadline = str_replace('{', '', $val); $comp_subheadline = str_replace('}', '', $comp_subheadline); if(isset($contents[$comp_subheadline])){ $html = str_replace($val, $contents[$comp_subheadline], $html); }else{ $html = str_replace($val, '', $html); } } } if(!empty($otherheadline_list[0])){ foreach($otherheadline_list[0] as $key=>$val){ $comp_otherheadline = str_replace('{', '', $val); $comp_otherheadline = str_replace('}', '', $comp_otherheadline); if(isset($contents[$comp_otherheadline])){ $html = str_replace($val, $contents[$comp_otherheadline], $html); }else{ $html = str_replace($val, '', $html); } } } if(!empty($text_list[0])){ foreach($text_list[0] as $key=>$val){ $comp_text = str_replace('{', '', $val); $comp_text = str_replace('}', '', $comp_text); if(isset($contents[$comp_text])){ $html = str_replace($val, $contents[$comp_text], $html); }else{ $html = str_replace($val, '', $html); } } } if(!empty($t_align_list[0])){ foreach($t_align_list[0] as $key=>$val){ $comp_t_align = str_replace('{', '', $val); $comp_t_align = str_replace('}', '', $comp_t_align); if(isset($contents[$comp_t_align])){ $html = str_replace($val, $contents[$comp_t_align], $html); }else{ $html = str_replace($val, '', $html); } } } if(!empty($image_list[0])){ foreach($image_list[0] as $key=>$val){ $comp_image = str_replace('{', '', $val); $comp_image = str_replace('}', '', $comp_image); //※※※パブリックイメージの暫定対応 if($contents[$comp_image] == 'no_image.jpg'){ $img_dir_path2 = '/common/public_image/'; }else{ $img_dir_path2 = $img_dir_path; } if(isset($contents[$comp_image])){ $html = str_replace($val, $img_dir_path2.$contents[$comp_image], $html); }else{ $html = str_replace($val, '', $html); } } } if(!empty($alt_list[0])){ foreach($alt_list[0] as $key=>$val){ $comp_alt = str_replace('{', '', $val); $comp_alt = str_replace('}', '', $comp_alt); if(isset($contents[$comp_alt])){ $html = str_replace($val, $contents[$comp_alt], $html); }else{ $html = str_replace($val, '', $html); } } } if(!empty($link_list[0])){ foreach($link_list[0] as $key=>$val){ $comp_link = str_replace('{', '', $val); $comp_link = str_replace('}', '', $comp_link); if(isset($contents[$comp_link])){ $html = str_replace($val, $contents[$comp_link], $html); }else{ $html = str_replace($val, '', $html); } } } if(!empty($other_list[0])){ foreach($other_list[0] as $key=>$val){ $comp_other = str_replace('{', '', $val); $comp_other = str_replace('}', '', $comp_other); if(isset($contents[$comp_other])){ $html = str_replace($val, $contents[$comp_other], $html); }else{ $html = str_replace($val, '', $html); } } } } //スマホ改行用 //$html = str_replace('\"\"', '', $html); $html = str_replace('', '
', $html); return $html; } public function routing(){ // //$this->autoRender = false; //$this->viewBuilder()->autoLayout(false); //REQUEST_URIに『.』を含む場合、ページでは無いので処理をスキップ //if(strpos($_SERVER['REQUEST_URI'],'.') === false){ // $data = []; //if(($company_data = Cache::read($_SERVER['HTTP_HOST'], 'company')) === false){ //企業情報取得 $query = $this->Companies->find() ->where(['Companies.status' => 1]) ->where(['Companies.delete_flag' => 0]); //顧客用サブドメインによるアクセスの場合 //if((strpos($_SERVER['HTTP_HOST'],'onerank-cms.com') !== false) && ($_SERVER['HTTP_HOST'] != 'onerank-cms.com')){ if((strpos($_SERVER['HTTP_HOST'],'onerank-cms.com') !== false && $_SERVER['HTTP_HOST'] != 'onerank-cms.com') || (strpos($_SERVER['HTTP_HOST'],'onerank-cms-2.com') !== false && $_SERVER['HTTP_HOST'] != 'onerank-cms-2.com') || (strpos($_SERVER['HTTP_HOST'],'onerank-cms-3.com') !== false && $_SERVER['HTTP_HOST'] != 'onerank-cms-3.com') || (strpos($_SERVER['HTTP_HOST'],'onerank-hybrid-dev.com') !== false && $_SERVER['HTTP_HOST'] != 'onerank-hybrid-dev.com') || (strpos($_SERVER['HTTP_HOST'],'onerank-hybrid-dev2.com') !== false && $_SERVER['HTTP_HOST'] != 'onerank-hybrid-dev2.com') || (strpos($_SERVER['HTTP_HOST'],'onerank-hybrid-dev3.com') !== false && $_SERVER['HTTP_HOST'] != 'onerank-hybrid-dev3.com') || (strpos($_SERVER['HTTP_HOST'],'ip-lambda.org') !== false && $_SERVER['HTTP_HOST'] != 'ip-lambda.org')){ $query->where(['Companies.subdomain' => SUB_DOMAIN]); $domain_name = $_SERVER['HTTP_HOST']; $www_mode = ''; $subdomain_mode = 'on'; //顧客専本ドメインによるアクセスの場合 }else{ //wwwありなしの確認 if(substr($_SERVER['HTTP_HOST'], 0, 4) == 'www.'){ //$www_mode = 'on'; $domain_name = str_replace('www.', '', $_SERVER['HTTP_HOST']); }else{ //$www_mode = 'off'; $domain_name = $_SERVER['HTTP_HOST']; } //$query->where(['Companies.domain' => $_SERVER['HTTP_HOST']]); $query->where(['Companies.domain' => $domain_name]); $subdomain_mode = 'off'; } $company_data = $query->first(); if(empty($company_data)){ return $this->redirect('404.html', '301'); } //キャッシュの書き込み //Cache::write($_SERVER['HTTP_HOST'], $company_data, 'company'); //Cache::delete($_SERVER['HTTP_HOST'], 'company'); //} //キャッシュの確認(セッティングデータ) //$tmp_setting = $this->setting_data($company_data->id); $tmp_tmp_setting = $this->setting_data($company_data->id); $tmp_setting = $tmp_tmp_setting['setting']; //※※※新バージョン用の分岐 if('aaa' == 'bbb'){ }else{ // if(!empty($tmp_setting->breadcrumb_text)){ $breadcrumb_text = $tmp_setting->breadcrumb_text; }else{ $breadcrumb_text = 'TOPページ'; } //wwwありなしの確認 if(substr($_SERVER['HTTP_HOST'], 0, 4) == 'www.'){ $www_mode = 'on'; $domain_name = str_replace('www.', '', $_SERVER['HTTP_HOST']); }else{ $www_mode = 'off'; $domain_name = $_SERVER['HTTP_HOST']; } //公開後のテスト環境から本番環境へのリダイレクト設定 if($www_mode == ''){ } //サブドメインから本ドメインへのリダイレクト //if($www_mode == '' && $company_data->domain_flag == 1){ if($subdomain_mode == 'on' && $company_data->domain_flag == 1){ if($tmp_setting->www_flag == 1){ return $this->redirect('https://'.$company_data->domain.$_SERVER['REQUEST_URI'], '301'); }elseif($tmp_setting->www_flag == 2){ return $this->redirect('https://www.'.$company_data->domain.$_SERVER['REQUEST_URI'], '301'); }else{ return $this->redirect('https://'.$company_data->domain.$_SERVER['REQUEST_URI'], '301'); } } //wwwありなしのリダイレクト設定 //www無し (www有りから無しにリダイレクト) if($tmp_setting->www_flag == 1 && $www_mode == 'on' && $subdomain_mode == 'off'){ return $this->redirect('https://'.$domain_name.$_SERVER['REQUEST_URI'], '301'); //www有り (www無しから有りにリダイレクト) }elseif($tmp_setting->www_flag == 2 && $www_mode == 'off' && $subdomain_mode == 'off'){ return $this->redirect('https://www.'.$domain_name.$_SERVER['REQUEST_URI'], '301'); //両方 (wwwありなしどちらでもアクセス可) }elseif($tmp_setting->www_flag == 3){ //未設定 }else{ } //recruit_id、遷移元の判別 $form_recruit_name = ''; $form_recruit_id = ''; if(!empty($this->request->getQuery('recruit_id')) && is_numeric($this->request->getQuery('recruit_id'))){ $form_recruit_id = $this->request->getQuery('recruit_id'); $form_recruit = $this->Recruits->find() ->where(['Recruits.id' => $form_recruit_id]) ->where(['Recruits.company_id' => $company_data->id]) ->where(['Recruits.delete_flag' => 0]) ->first(); if(!empty($form_recruit)){ $form_recruit_name = $form_recruit->title; } } $this->set('form_recruit_id', $form_recruit_id); $this->set('form_recruit_name', $form_recruit_name); //パラメータ処理 $preview_mode = false; $iframe_mode = false; $hash_tag = ''; /*if($_SERVER['REMOTE_ADDR'] == '219.113.215.10'){ var_dump('Areus事務所固定IPアドレスのみ表示している一時的なデバッグです'); var_dump($_SERVER['REQUEST_URI']); }*/ if(strpos($_SERVER['REQUEST_URI'], '?mode=preview') !== false){ $request_uri = strstr($_SERVER['REQUEST_URI'], '?', TRUE); $preview_mode = true; //iframe }elseif(strpos($_SERVER['REQUEST_URI'], '?mode=iframe') !== false){ $request_uri = strstr($_SERVER['REQUEST_URI'], '?', TRUE); $iframe_mode = true; //HashTag /*}elseif(strpos($_SERVER['REQUEST_URI'], '#') !== false){ $request_uri = strstr($_SERVER['REQUEST_URI'], '#', TRUE); $hash_tag = strstr($_SERVER['REQUEST_URI'], '#'); $hash_tag = str_replace('#', '', $hash_tag);*/ }elseif(strpos($_SERVER['REQUEST_URI'], '?') !== false){ $request_uri = strstr($_SERVER['REQUEST_URI'], '?', TRUE); }else{ $request_uri = $_SERVER['REQUEST_URI']; } if(empty($company_data)){ $company_data = new \stdClass; $company_data->id = ''; } //末尾にスラッシュが付いていない場合の対応 if(substr($request_uri, -1) != '/'){ $request_uri = $request_uri.'/'; } //変数定義 $slug = ''; $page_num = ''; $fixed_slug = ''; $fixed_slug2 = ''; $tag_category = ''; $page_mode = ''; $page_tag = ''; $form_block_id = ''; $archive_year = ''; $archive_month = ''; //第二回層以降にブログを設置している際の対応 /*$request_uri2 = $request_uri; if(strpos($request_uri, 'category') !== false){ $request_uri2 = strstr($request_uri, 'category', true); }*/ //slug_plusが存在するか確認 $page_slug_plus = $this->Pages->find() ->contain(['Pagetypes', 'Tags', 'BlogCategories']) ->where(['Pages.company_id' => $company_data->id]) ->where(['Pages.pagetype_id IN' => [1, 2, 3, 4, 5, 8, 10, 12]]) ->where(['Pages.slug_plus' => $request_uri]) ->where(['Pages.display_flag' => 1]) ->where(['Pages.delete_flag' => 0]) ->first(); // if($request_uri != '' && $request_uri != '/'){ //リダイレクト処理 if(!empty($page_slug_plus)){ $request_uri_plus = $page_slug_plus->slug; }else{ $request_uri_plus = $request_uri; $request_uri_plus = ltrim($request_uri_plus, '/'); $request_uri_plus = rtrim($request_uri_plus, '/'); $request_uri_plus = urlencode($request_uri_plus); $request_uri_plus = str_replace('%2F', '/', $request_uri_plus); } $redirect = $this->Redirects->find() ->select(['Redirects.id', 'Redirects.slug', 'Redirects.slug_plus', 'Redirects.r_slug', 'Redirects.status_code']) ->where(['Redirects.company_id' => $company_data->id]) //->where(['Redirects.slug' => $slug]) //->where(['Redirects.slug_plus' => $slug]) ->where(['Redirects.slug' => $request_uri_plus]) ->where(['Redirects.delete_flag' => 0]) ->first(); if(!empty($redirect)){ //TOPへのリダイレクト if(empty($redirect->r_slug)){ return $this->redirect('/', $redirect->status_code); //TOP以外へのリダイレクト }else{ //リダイレクト先にさらにリダイレクトがあるか確認 $tmp_redirect = $this->Redirects->find() ->select(['Redirects.id', 'Redirects.slug', 'Redirects.r_slug', 'Redirects.status_code']) ->where(['Redirects.company_id' => $company_data->id]) //->where(['Redirects.slug' => $redirect->r_slug]) //->where(['Redirects.slug_plus' => $redirect->r_slug]) ->where(['Redirects.slug' => $redirect->r_slug]) ->where(['Redirects.delete_flag' => 0]) ->first(); //2段階以上のリダイレクトの場合、処理を中止してTOPに強制リダイレクト if(!empty($tmp_redirect)){ return $this->redirect('/', '301'); }else{ return $this->redirect('/'.$redirect->r_slug.'/', $redirect->status_code); } } } } if(!empty($page_slug_plus) && $request_uri != '' && $request_uri != '/'){ //if($request_uri != '' && $request_uri != '/' && strpos($request_uri, 'archive') === false){ //リダイレクト処理 /*if(!empty($page_slug_plus)){ $request_uri_plus = $page_slug_plus->slug; }else{ $request_uri_plus = $request_uri; $request_uri_plus = ltrim($request_uri_plus, '/'); $request_uri_plus = rtrim($request_uri_plus, '/'); $request_uri_plus = urlencode($request_uri_plus); $request_uri_plus = str_replace('%2F', '/', $request_uri_plus); } $redirect = $this->Redirects->find() ->select(['Redirects.id', 'Redirects.slug', 'Redirects.slug_plus', 'Redirects.r_slug', 'Redirects.status_code']) ->where(['Redirects.company_id' => $company_data->id]) //->where(['Redirects.slug' => $slug]) //->where(['Redirects.slug_plus' => $slug]) ->where(['Redirects.slug' => $request_uri_plus]) ->where(['Redirects.delete_flag' => 0]) ->first(); if(!empty($redirect)){ //TOPへのリダイレクト if(empty($redirect->r_slug)){ return $this->redirect('/', $redirect->status_code); //TOP以外へのリダイレクト }else{ //リダイレクト先にさらにリダイレクトがあるか確認 $tmp_redirect = $this->Redirects->find() ->select(['Redirects.id', 'Redirects.slug', 'Redirects.r_slug', 'Redirects.status_code']) ->where(['Redirects.company_id' => $company_data->id]) //->where(['Redirects.slug' => $redirect->r_slug]) //->where(['Redirects.slug_plus' => $redirect->r_slug]) ->where(['Redirects.slug' => $redirect->r_slug]) ->where(['Redirects.delete_flag' => 0]) ->first(); //2段階以上のリダイレクトの場合、処理を中止してTOPに強制リダイレクト if(!empty($tmp_redirect)){ return $this->redirect('/', '301'); }else{ return $this->redirect('/'.$redirect->r_slug.'/', $redirect->status_code); } } }*/ // $data['page'] = $page_slug_plus; $company_id = $company_data->id; //ブロックデータの処理 if(!empty($data['page']->block_order)){ $tmp_data = $this->block_data($company_data->id, $data['page']->block_order, $fixed_slug, $form_block_id, 'main'); $data['blocks'] = $tmp_data['blocks']; $data['block_other'] = $tmp_data['block_other']; if(isset($tmp_data['form_input_data'])){ $data['form_input_data'] = $tmp_data['form_input_data']; }else{ $data['form_input_data'] = ''; } }else{ $data['blocks'] = ''; $data['block_other'] = ''; $data['form_input_data'] = ''; } //※※※pageが記事(pagetypeが6)の場合、関連記事の取得をどうするか //上下階層の前ページを取得する様に仕様変更 //最上位のpage_idを$tmp_parent_idにセット $tmp_hierarchy_id = $data['page']->id; $tmp_parent_id = $data['page']->parent_id; while($tmp_parent_id != 0){ $tmp_child_page = $this->Pages->find() ->where(['Pages.company_id' => $company_id]) ->where(['Pages.id' => $tmp_parent_id]) ->first(); $tmp_hierarchy_id = $tmp_child_page->id; $tmp_parent_id = $tmp_child_page->parent_id; } // $data['hierarchies'] = []; $relations_not_id_array = []; $relations_not_id_array[] = $data['page']->id; //TOPを第一階層とした場合、第二回層のデータ1件を取得 if($data['page']->id != $tmp_hierarchy_id){ $tmp_hierarchy = $this->Pages->find() ->select(['Pages.id', 'Pages.pagetype_id', 'Pages.parent_id', 'Pages.name', 'Pages.slug', 'Pages.slug_plus', 'Pages.title', 'Pages.sort', 'Pages.description', 'Pages.image01', 'Pagetypes.id', 'Pagetypes.name']) ->contain(['Pagetypes']) ->where(['Pages.company_id' => $company_id]) ->where(['Pages.id' => $tmp_hierarchy_id]) ->where(['OR' => [['Pages.pagetype_id' => 2], ['Pages.pagetype_id' => 3], ['Pages.pagetype_id' => 4], ['Pages.pagetype_id' => 5], ['Pages.pagetype_id' => 12]]]) ->where(['Pages.display_flag' => 1]) ->where(['Pages.delete_flag' => 0]) ->first(); if(!empty($tmp_hierarchy)){ $data['hierarchies'][] = $tmp_hierarchy; $relations_not_id_array[] = $tmp_hierarchy->id; } } //TOPを第一階層とした場合、第二回層のデータ1件に紐付く第三階層のデータを複数取得 $tmp_hierarchies1 = $this->Pages->find() ->select(['Pages.id', 'Pages.pagetype_id', 'Pages.parent_id', 'Pages.name', 'Pages.slug', 'Pages.slug_plus', 'Pages.title', 'Pages.sort', 'Pages.description', 'Pages.image01', 'Pagetypes.id', 'Pagetypes.name']) ->contain(['Pagetypes']) ->where(['Pages.id !=' => $data['page']->id]) ->where(['Pages.company_id' => $company_id]) ->where(['Pages.parent_id' => $tmp_hierarchy_id]) ->where(['OR' => [['Pages.pagetype_id' => 2], ['Pages.pagetype_id' => 3], ['Pages.pagetype_id' => 4], ['Pages.pagetype_id' => 5], ['Pages.pagetype_id' => 12]]]) ->where(['Pages.display_flag' => 1]) ->where(['Pages.delete_flag' => 0]) ->all(); if(!$tmp_hierarchies1->isEmpty()){ foreach($tmp_hierarchies1 as $tmp_hierarchy1){ // $data['hierarchies'][] = $tmp_hierarchy1; $relations_not_id_array[] = $tmp_hierarchy1->id; //TOPを第一階層とした場合、第三回層のデータ1件に紐付く第四階層のデータを複数取得 $tmp_hierarchies2 = $this->Pages->find() ->select(['Pages.id', 'Pages.pagetype_id', 'Pages.parent_id', 'Pages.name', 'Pages.slug', 'Pages.slug_plus', 'Pages.title', 'Pages.sort', 'Pages.description', 'Pages.image01', 'Pagetypes.id', 'Pagetypes.name']) ->contain(['Pagetypes']) ->where(['Pages.id !=' => $data['page']->id]) ->where(['Pages.company_id' => $company_id]) ->where(['Pages.parent_id' => $tmp_hierarchy1->id]) ->where(['OR' => [['Pages.pagetype_id' => 2], ['Pages.pagetype_id' => 3], ['Pages.pagetype_id' => 4], ['Pages.pagetype_id' => 5], ['Pages.pagetype_id' => 12]]]) ->where(['Pages.display_flag' => 1]) ->where(['Pages.delete_flag' => 0]) ->all(); if(!$tmp_hierarchies2->isEmpty()){ foreach($tmp_hierarchies2 as $tmp_hierarchy2){ $data['hierarchies'][] = $tmp_hierarchy2; $relations_not_id_array[] = $tmp_hierarchy2->id; } } } } //関連度の高いページを取得※※※aaa $data['relations'] = []; $relation_data = []; //フレーム一覧を取得 $query = $this->Pages->find('all') //->select(['Pages.id', 'Pages.name', 'Pages.slug', 'Pagetypes.name', 'Pagetypes.abbr', 'Tags.name']) ->select(['Pages.id', 'Pages.parent_id', 'Pages.name', 'Pages.slug', 'Pages.content', 'Pages.image01', 'Pages.description']) ->contain(['Tags']) ->where(['Pages.company_id' => $company_id]) //TOPと固定ページのみ対象 ->where(['Pages.pagetype_id IN' => [1, 4]]) ->where(['Pages.display_flag' => 1]) ->where(['Pages.delete_flag' => 0]) ->where([ 'NOT' => ['Pages.id IN' => $relations_not_id_array] ]) ->order(['Pages.sort' => 'ASC']); //->toArray(); $relation_data['pages'] = $query->toArray(); // //$return_data = []; if(!empty($relation_data['pages'])){ //TOP $count = 1; /*foreach($relation_data['pages'] as $row){ if(is_null($row->parent_id)){ $save_data['name'] = $row->name; $save_data['image01'] = $row->image01; $save_data['layer_num'] = 1; $save_data['slug_plus'] = '/'; //該当ページの文字数 $total_count = mb_strlen($row->content, 'UTF-8'); if($total_count != 0){ // $match_rate = 0; foreach($data['page']->tags as $tmp_tag){ //キーワードの出現回数 $occurrences = mb_substr_count($row->content, $tmp_tag->name); //キーワードのトータル文字数 $keyword_count = mb_strlen($tmp_tag->name, 'UTF-8') * $occurrences; //キーワード占有率 $match_rate = $match_rate + ($keyword_count / $total_count * 100); } $save_data['match_rate'] = round($match_rate, 2); }else{ $save_data['match_rate'] = 0; } $data['relations'][] = $save_data; $count++; } }*/ foreach($relation_data['pages'] as $row1){ if($row1->parent_id == 0 && !is_null($row1->parent_id)){ $save_data['id'] = $row1->id; $save_data['name'] = $row1->name; $save_data['image01'] = $row1->image01; $save_data['layer_num'] = 2; $save_data['slug_plus'] = '/'.$row1->slug.'/'; $save_data['description'] = $row1->description; //該当ページの文字数 $total_count = mb_strlen($row1->content, 'UTF-8'); if($total_count != 0){ // $match_rate = 0; foreach($data['page']->tags as $tmp_tag){ //キーワードの出現回数 $occurrences = mb_substr_count($row1->content, $tmp_tag->name); //キーワードのトータル文字数 $keyword_count = mb_strlen($tmp_tag->name, 'UTF-8') * $occurrences; //キーワード占有率 $match_rate = $match_rate + ($keyword_count / $total_count * 100); } if(round($match_rate, 2) == 0){ $save_data['match_rate'] = 0; }else{ $save_data['match_rate'] = round($match_rate, 2).$count; $data['relations'][]= $save_data; $count++; } }else{ $save_data['match_rate'] = 0; } //$data['relations'][]= $save_data; //$count++; foreach($relation_data['pages'] as $row2){ if($row2->parent_id == $row1->id){ $save_data['id'] = $row2->id; $save_data['name'] = $row2->name; $save_data['image01'] = $row2->image01; $save_data['layer_num'] = 3; $save_data['slug_plus'] = '/'.$row1->slug.'/'.$row2->slug.'/'; $save_data['description'] = $row2->description; //該当ページの文字数 $total_count = mb_strlen($row2->content, 'UTF-8'); if($total_count != 0){ // $match_rate = 0; foreach($data['page']->tags as $tmp_tag){ //キーワードの出現回数 $occurrences = mb_substr_count($row2->content, $tmp_tag->name); //キーワードのトータル文字数 $keyword_count = mb_strlen($tmp_tag->name, 'UTF-8') * $occurrences; //キーワード占有率 $match_rate = $match_rate + ($keyword_count / $total_count * 100); } if(round($match_rate, 2) == 0){ $save_data['match_rate'] = 0; }else{ $save_data['match_rate'] = round($match_rate, 2).$count; $data['relations'][] = $save_data; $count++; } }else{ $save_data['match_rate'] = 0; } //$data['relations'][] = $save_data; //$count++; foreach($relation_data['pages'] as $row3){ if($row3->parent_id == $row2->id){ $save_data['id'] = $row3->id; $save_data['parent_id'] = $row2->id; $save_data['name'] = $row3->name; $save_data['image01'] = $row3->image01; $save_data['layer_num'] = 4; $save_data['slug_plus'] = '/'.$row1->slug.'/'.$row2->slug.'/'.$row3->slug.'/'; $save_data['description'] = $row3->description; //該当ページの文字数 $total_count = mb_strlen($row3->content, 'UTF-8'); if($total_count != 0){ // $match_rate = 0; foreach($data['page']->tags as $tmp_tag){ //キーワードの出現回数 $occurrences = mb_substr_count($row3->content, $tmp_tag->name); //キーワードのトータル文字数 $keyword_count = mb_strlen($tmp_tag->name, 'UTF-8') * $occurrences; //キーワード占有率 $match_rate = $match_rate + ($keyword_count / $total_count * 100); } if(round($match_rate, 2) == 0){ $save_data['match_rate'] = 0; }else{ $save_data['match_rate'] = round($match_rate, 2).$count; $data['relations'][] = $save_data; $count++; } }else{ $save_data['match_rate'] = 0; } //$data['relations'][] = $save_data; //$count++; } } } } } } } //sort用のID配列 $match_rate = []; foreach($data['relations'] as $key=>$val){ $match_rate[$key] = $val['match_rate']; } array_multisort($match_rate, SORT_DESC, $data['relations']); //$this->log($data['relations'], 'debug'); //パンくずリスト $data['breadcrumb'] = []; // if(!empty($data['page'])){ // if(!empty($tag_category) && $fixed_slug == 'category'){ $data['breadcrumb'][5]['url'] = '/'.$data['page']->slug.'/category/'.$tag_category.'/'; $data['breadcrumb'][5]['name'] = urldecode($tag_category); } // if($data['page']->parent_id != null or $data['page']->parent_id == '0'){ if($data['page']->pagetype_id == 6){ $bc4_slug = 'detail/'.$data['page']->slug; }else{ $bc4_slug = $data['page']->slug; } //$data['breadcrumb'][4]['url'] = '/'.$data['page']->slug.'/'; $data['breadcrumb'][4]['url'] = '/'.$bc4_slug.'/'; $data['breadcrumb'][4]['name'] = $data['page']->name; $data['breadcrumb'][4]['id'] = $data['page']->id; if($data['page']->parent_id != '0'){ $bc3 = $this->Pages->get($data['page']->parent_id); $data['breadcrumb'][3]['url'] = '/'.$bc3->slug.'/'; $data['breadcrumb'][3]['name'] = $bc3->name; $data['breadcrumb'][3]['id'] = $bc3->id; $data['breadcrumb'][4]['url'] = '/'.$bc3->slug.$data['breadcrumb'][4]['url']; if($bc3->parent_id != '0'){ $bc2 = $this->Pages->get($bc3->parent_id); $data['breadcrumb'][2]['url'] = '/'.$bc2->slug.'/'; $data['breadcrumb'][2]['name'] = $bc2->name; $data['breadcrumb'][2]['id'] = $bc2->id; $data['breadcrumb'][3]['url'] = '/'.$bc2->slug.$data['breadcrumb'][3]['url']; $data['breadcrumb'][4]['url'] = '/'.$bc2->slug.$data['breadcrumb'][4]['url']; } } }else{ $data['breadcrumb'][2]['url'] = '/'; $data['breadcrumb'][2]['name'] = '指定されたページはございません'; } $data['breadcrumb'][1]['url'] = '/'; $data['breadcrumb'][1]['name'] = $breadcrumb_text; } // // $data['breadcrumb'] = array_reverse($data['breadcrumb']); //キャッシュの書き込み ※※※ //Cache::write($company_id.'_'.$slug.'_page', $data, 'page'); //slug_plus実装前の処理方法 }else{ // $request_uri_array = explode('/', $request_uri); $request_uri_array = array_filter($request_uri_array, "strlen"); //問い合わせ系の事前処理 /*if ($this->request->is('post')) { $form_block_id = $this->request->data['block_id']; }else{ $form_block_id = ''; }*/ //$slug_name = ''; //$slug = end($request_uri_array); //ブログのカテゴリやタグなどのアーカイブ系(固定スラッグ)や、ページネーション系の為の処理 if(!empty($request_uri_array)){ //$fixed_slug_array = ['archive','detail','category','tag']; //$fixed_slug_array = ['archive','category','tag', 'form_conf', 'form_send']; //$fixed_slug_array = ['archive','gallery_archive','comparison_archive','dictionary','category','tag', 'form_conf', 'form_send']; //$fixed_slug_array = ['archive','dictionary','category','tag', 'form_conf', 'form_send']; $fixed_slug_array = ['archive','dictionary','category','tag']; $fixed_slug_array2 = ['gallery_archive','comparison_archive']; $reverse_request_uri_array = array_reverse($request_uri_array); //末尾に数字が付くか付かないか if(is_numeric($reverse_request_uri_array[0])){ //数字のみのslugかどうか判別 $slug_check = $this->Pages->find() ->where(['Pages.company_id' => $company_data->id]) ->where(['Pages.slug' => $reverse_request_uri_array[0]]) ->first(); //form_conf・form_sendのIDの場合の処理 if((isset($reverse_request_uri_array[1]) && $reverse_request_uri_array[1] == 'form_conf') || (isset($reverse_request_uri_array[1]) && $reverse_request_uri_array[1] == 'form_send')){ $fixed_slug = $reverse_request_uri_array[1]; if(isset($reverse_request_uri_array[2])){ $slug = $reverse_request_uri_array[2]; }else{ $slug = ''; } $form_block_id = $reverse_request_uri_array[0]; //ブログ・新着情報、年月アーカイブ(ページネーション無し)/blog/archive/2019/04/ }elseif(isset($reverse_request_uri_array[2]) && $reverse_request_uri_array[2] == 'archive'){ $slug = $reverse_request_uri_array[3]; $fixed_slug = 'archive'; $archive_year = $reverse_request_uri_array[1]; $archive_month = $reverse_request_uri_array[0]; $page_num = ''; //ブログ・新着情報、年月アーカイブ(ページネーション有り)/blog/archive/2019/04/2/ }elseif(isset($reverse_request_uri_array[3]) && $reverse_request_uri_array[3] == 'archive'){ $slug = $reverse_request_uri_array[4]; $fixed_slug = 'archive'; $archive_year = $reverse_request_uri_array[2]; $archive_month = $reverse_request_uri_array[1]; $page_num = $reverse_request_uri_array[0]; //ブログ・新着情報記事 }elseif(!empty($slug_check)){ $slug = $reverse_request_uri_array[0]; //新ギャラリーの詳細の場合を追加 }elseif(isset($reverse_request_uri_array[1]) && $reverse_request_uri_array[1] == 'detail'){ $tag_category = $reverse_request_uri_array[0]; $fixed_slug = $reverse_request_uri_array[1]; $slug = $reverse_request_uri_array[2]; }elseif(!isset($reverse_request_uri_array[1])){ //return $this->redirect('/', '301'); $slug = 'cccccccccccccccccccccccccccccccccccccccccccccc'; }else{ $page_num = $reverse_request_uri_array[0]; if(!isset($reverse_request_uri_array[1])){ $fixed_slug = ''; $slug = 'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa'; }else{ if(in_array($reverse_request_uri_array[1], $fixed_slug_array)){ $fixed_slug = $reverse_request_uri_array[1]; $slug = $reverse_request_uri_array[2]; }elseif(isset($reverse_request_uri_array[2]) && in_array($reverse_request_uri_array[2], $fixed_slug_array)){ $tag_category = $reverse_request_uri_array[1]; $fixed_slug = $reverse_request_uri_array[2]; $slug = $reverse_request_uri_array[3]; }elseif(isset($reverse_request_uri_array[2]) && in_array($reverse_request_uri_array[2], $fixed_slug_array2)){ $page_num = $reverse_request_uri_array[0]; $fixed_slug = $reverse_request_uri_array[2]; $slug = $reverse_request_uri_array[1]; }elseif(isset($reverse_request_uri_array[1]) && in_array($reverse_request_uri_array[1], $fixed_slug_array2)){ $page_num = 1; $fixed_slug = $reverse_request_uri_array[1]; $slug = $reverse_request_uri_array[0]; }else{ $slug = $reverse_request_uri_array[1]; } } } }else{ if(isset($reverse_request_uri_array[0]) && in_array($reverse_request_uri_array[0], $fixed_slug_array2)){ return $this->redirect('/'.$reverse_request_uri_array[0].'/all/', '301'); } if(in_array($reverse_request_uri_array[0], $fixed_slug_array)){ $page_num = 1; $fixed_slug = $reverse_request_uri_array[0]; //TOPページ以外の場合 if(isset($reverse_request_uri_array[1])){ $slug = $reverse_request_uri_array[1]; //TOPページの場合 }else{ $slug = ''; } //$slug = $reverse_request_uri_array[1]; }elseif(isset($reverse_request_uri_array[1]) && in_array($reverse_request_uri_array[1], $fixed_slug_array)){ $page_num = 1; $tag_category = $reverse_request_uri_array[0]; $fixed_slug = $reverse_request_uri_array[1]; $slug = $reverse_request_uri_array[2]; // }elseif(isset($reverse_request_uri_array[1]) && in_array($reverse_request_uri_array[1], $fixed_slug_array2)){ $page_num = 1; $fixed_slug = $reverse_request_uri_array[1]; $slug = $reverse_request_uri_array[0]; //gallery_archiveやcomparison_archiveでパラメータが付いていない=全件表示の場合の処理 }elseif(isset($reverse_request_uri_array[0]) && in_array($reverse_request_uri_array[0], $fixed_slug_array2)){ $page_num = 1; $fixed_slug = $reverse_request_uri_array[0]; $slug = ''; }else{ $slug = $reverse_request_uri_array[0]; } } //固定スラッグがdetailの場合の処理 if(isset($reverse_request_uri_array[1]) && $reverse_request_uri_array[1] == 'detail'){ //辞書の詳細ページの場合 if(isset($reverse_request_uri_array[2]) && $reverse_request_uri_array[2] == 'dictionary'){ $page_mode = 'dictionary'; $fixed_slug = 'detail'; $slug = $reverse_request_uri_array[0]; //ブログや新着情報、特集の詳細ページの場合 }else{ $fixed_slug = 'detail'; //$slug = $reverse_request_uri_array[0]; } } //固定スラッグがgallery_archive,comparison_archive if($fixed_slug == 'gallery_archive' || $slug == 'gallery_archive'){ $page_mode = 'gallery_archive'; }elseif($fixed_slug == 'comparison_archive'){ $page_mode = 'comparison_archive'; }elseif($fixed_slug == 'tag'){ $page_mode = 'tag'; } //固定スラッグがcategoryやtagの場合、slugの内容を書き換え /*if($fixed_slug == 'category' || $fixed_slug == 'tag'){ $slug_name = $slug; }*/ }else{ $slug = ''; } //リダイレクト処理 $request_uri_plus = ltrim($request_uri, '/'); $request_uri_plus = rtrim($request_uri_plus, '/'); $redirect = $this->Redirects->find() ->select(['Redirects.id', 'Redirects.slug', 'Redirects.slug_plus', 'Redirects.r_slug', 'Redirects.status_code']) ->where(['Redirects.company_id' => $company_data->id]) //->where(['Redirects.slug' => $slug]) //->where(['Redirects.slug_plus' => $slug]) ->where(['Redirects.slug' => $request_uri_plus]) ->where(['Redirects.delete_flag' => 0]) ->first(); if(!empty($redirect)){ //TOPへのリダイレクト if(empty($redirect->r_slug)){ return $this->redirect('/', $redirect->status_code); //TOP以外へのリダイレクト }else{ //リダイレクト先にさらにリダイレクトがあるか確認 $tmp_redirect = $this->Redirects->find() ->select(['Redirects.id', 'Redirects.slug', 'Redirects.r_slug', 'Redirects.status_code']) ->where(['Redirects.company_id' => $company_data->id]) //->where(['Redirects.slug' => $redirect->r_slug]) //->where(['Redirects.slug_plus' => $redirect->r_slug]) ->where(['Redirects.slug' => $redirect->r_slug]) ->where(['Redirects.delete_flag' => 0]) ->first(); //2段階以上のリダイレクトの場合、処理を中止してTOPに強制リダイレクト if(!empty($tmp_redirect)){ return $this->redirect('/', '301'); }else{ return $this->redirect('/'.$redirect->r_slug.'/', $redirect->status_code); } } } //URL構造が正しいかチェック $this->request_uri_check($company_data->id, $slug, $fixed_slug, $request_uri, $page_num); //キャッシュの確認(セッティングデータ) ↑上に移行 //$tmp_setting = $this->setting_data($company_data->id); //キャッシュの確認(ページデータ) $data = $this->page_data($company_data->id, $slug, $fixed_slug, $form_block_id, $tag_category, $preview_mode, $page_mode, $breadcrumb_text, $tmp_setting, $request_uri); } if($_SERVER['REMOTE_ADDR'] == '202.12.244.43'){ //var_dump($data); } //サブナビゲーション $navigation_page_id = ''; if(!empty($data['page']->navigation_id)){ $navigation_data = $this->Navigations->find() ->where(['Navigations.id' => $data['page']->navigation_id]) ->where(['Navigations.company_id' => $company_data->id]) ->where(['Navigations.delete_flag' => 0]) ->first(); if(!empty($navigation_data)){ $tmp_setting->loading_image = $navigation_data->loading_image; $tmp_setting->common_tel = $navigation_data->common_tel; $tmp_setting->common_address = $navigation_data->common_address; $tmp_setting->common_hour = $navigation_data->common_hour; $tmp_setting->logo_image = $navigation_data->logo_image; $tmp_setting->header_logo_link = $navigation_data->header_logo_link; $tmp_setting->translate_flag = $navigation_data->translate_flag; $tmp_setting->h_tel_flag = $navigation_data->h_tel_flag; $tmp_setting->h_address_flag = $navigation_data->h_address_flag; $tmp_setting->h_hour_flag = $navigation_data->h_hour_flag; $tmp_setting->h_button_flag = $navigation_data->h_button_flag; $tmp_setting->header_link_type = $navigation_data->header_link_type; $tmp_setting->header_link = $navigation_data->header_link; $tmp_setting->header_text = $navigation_data->header_text; $tmp_setting->header_link_target = $navigation_data->header_link_target; $tmp_setting->text_align_flag = $navigation_data->text_align_flag; $tmp_setting->footer_image = $navigation_data->footer_image; $tmp_setting->footer_logo_link = $navigation_data->footer_logo_link; $tmp_setting->footer_flag = $navigation_data->footer_flag; $tmp_setting->f_tel_flag = $navigation_data->f_tel_flag; $tmp_setting->f_hour_flag = $navigation_data->f_hour_flag; $tmp_setting->f_button_flag = $navigation_data->f_button_flag; $tmp_setting->footer_link_type = $navigation_data->footer_link_type; $tmp_setting->footer_link = $navigation_data->footer_link; $tmp_setting->footer_text = $navigation_data->footer_text; $tmp_setting->footer_link_target = $navigation_data->footer_link_target; $tmp_setting->mystyle_css = $navigation_data->mystyle_css; $tmp_setting->css_font = $navigation_data->css_font; // $navigation_page_id = $navigation_data->page_id; $data['navigation_page_id'] = $navigation_page_id; } } //※※※暫定処理※※※ if($slug != 'gallery_archive'){ if($fixed_slug == 'detail' && $data['page']->pagetype_id == '4'){ //※※※第階層のギャラリーの場合、詳細ページ表示時に親ページが正常に取得できないので暫定的にコメントアウト //return $this->redirect('/'.$data['page']->slug.'/', '301'); } } // if(!empty($company_data->domain)){ $data['site_url'] = 'https://'.$company_data->domain; }else{ if(SV_KIND2 == 'IPP3_1'){ $data['site_url'] = 'https://'.$company_data->subdomain.'.onerank-cms.com'; }elseif(SV_KIND2 == 'IPP3_2'){ $data['site_url'] = 'https://'.$company_data->subdomain.'.onerank-cms-2.com'; }elseif(SV_KIND2 == 'IPP3_3'){ $data['site_url'] = 'https://'.$company_data->subdomain.'.onerank-cms-3.com'; }elseif(SV_KIND2 == 'dev(AWS)'){ $data['site_url'] = 'https://'.$company_data->subdomain.'.onerank-hybrid-dev.com'; }elseif(SV_KIND2 == 'dev2(AWS)'){ $data['site_url'] = 'https://'.$company_data->subdomain.'.onerank-hybrid-dev2.com'; }elseif(SV_KIND2 == 'dev3(AWS)'){ $data['site_url'] = 'https://'.$company_data->subdomain.'.onerank-hybrid-dev3.com'; } } //キャッシュの確認(共通フッターデータ) if(!empty($tmp_setting->footer_block_order)){ $tmp_data = $this->block_data($company_data->id, $tmp_setting->footer_block_order, $fixed_slug, $form_block_id, 'footer'); $data['footer_blocks'] = $tmp_data['blocks']; $data['footer_block_other'] = $tmp_data['block_other']; if(isset($tmp_data['form_input_data'])){ $data['form_input_data'] = $tmp_data['form_input_data']; }else{ $data['form_input_data'] = ''; } }else{ $data['footer_blocks'] = ''; $data['footer_block_other'] = ''; $data['form_input_data'] = ''; } //ログイン状態の確認 if($this->Cookie->check('ipp_lambda_admin_base')){ $cookie_data = $this->Cookie->read('ipp_lambda_admin_base'); //if($cookie_data['company_domain'] == $_SERVER['HTTP_HOST'] || $cookie_data['company_subdomain'].'.onerank-cms.com' == $_SERVER['HTTP_HOST']){ if($cookie_data['company_domain'] == $domain_name || $cookie_data['company_subdomain'].'.onerank-cms.com' == $domain_name || $cookie_data['company_subdomain'].'.onerank-cms-2.com' == $domain_name || $cookie_data['company_subdomain'].'.onerank-cms-3.com' == $domain_name || $cookie_data['company_subdomain'].'.onerank-hybrid-dev.com' == $domain_name || $cookie_data['company_subdomain'].'.onerank-hybrid-dev2.com' == $domain_name || $cookie_data['company_subdomain'].'.onerank-hybrid-dev3.com' == $domain_name){ $data['login_state'] = 'login'; $data['user_name'] = $cookie_data['user_name']; }else{ $data['login_state'] = 'logout'; } }else{ $data['login_state'] = 'logout'; } //キャッシュの確認(辞書データ) //if($page_mode != 'dictionary'){ /*if(isset($data['blocks']) && !empty($data['blocks'])){ $data['blocks'] = $this->dictionary_data($company_data->id, $slug, $data['blocks'], $iframe_mode); }*/ if(isset($data['blocks']) && !empty($data['blocks']) && $tmp_setting->dictionary_mode != 2){ $data['blocks'] = $this->dictionary_data($company_data->id, $slug, $data['blocks'], $tmp_setting->dictionary_mode, $tmp_setting->dictionary_tooltip, $iframe_mode); } //キャッシュの確認(セッティングデータ) $data['setting'] = $tmp_setting; //text-align $data['text_align'] = ''; if($data['setting']->text_align_flag == 1){ $data['text_align'] = ' align-center'; }elseif($data['setting']->text_align_flag == 2){ $data['text_align'] = ' align-right'; } // $data['pagenation'] = []; //キャッシュの確認(アーカイブ・カテゴリ・タグの場合、追加データ取得) //$tag_category = $tag_category;//※※※ この記述いる? //if(isset($data['page']->pagetype_id)){ if(isset($data['page']->pagetype_id) && $page_mode != 'dictionary'){ if(($fixed_slug == 'archive' || $fixed_slug == 'category' || $fixed_slug == 'tag') || ($data['page']->pagetype_id == 2 || $data['page']->pagetype_id == 3 || $data['page']->pagetype_id == 5 || $data['page']->pagetype_id == 12)){ $articles = ''; //固定ページ用のタグに紐付く一覧の場合 if($slug == 'page'){ $page_tag = urldecode($tag_category); $query = $this->Pages->find() ->select(['Pages.id', 'Pages.slug', 'Pages.name', 'Pages.company_id', 'Pages.pagetype_id', 'Pages.release_date', 'Pages.description', 'Pages.display_flag', 'Pages.delete_flag', 'PagesTags.id', 'PagesTags.page_id', 'PagesTags.tag_id', 'Tags.id', 'Tags.company_id', 'Tags.name', 'Tags.slug', 'Tags.content', 'Tags.sort', 'Tags.display_flag']) ->where(['Pages.company_id' => $company_data->id]) //->where(['Pages.parent_id' => $data['page']->id]) ->where(['OR' => [['Pages.pagetype_id' => 1], ['Pages.pagetype_id' => 2], ['Pages.pagetype_id' => 3], ['Pages.pagetype_id' => 4], ['Pages.pagetype_id' => 5], ['Pages.pagetype_id' => 6], ['Pages.pagetype_id' => 12]]]) ->where(['Pages.display_flag' => 1]) ->where(['Pages.delete_flag' => 0]) //スロークエリ改善 //->order(['release_date' => 'DESC']); ->order(['Pages.id' => 'DESC']); // $article_tag = urldecode($tag_category); // $tmp_tag = $this->Tags->find() ->where(['Tags.company_id' => $company_data->id]) ->where(['Tags.name' => urldecode($tag_category)]) ->first(); // /*$query->matching('Tags', function($q)use($tag_category) { //return $q->where(['BlogCategories.slug' => $tag_category]); return $q->where(['Tags.name' => urldecode($tag_category)]); });*/ $tmp_tag_id = $tmp_tag->id; $query->matching('Tags', function($q)use($tmp_tag_id) { //return $q->where(['BlogCategories.slug' => $tag_category]); return $q->where(['Tags.id' => $tmp_tag_id]); }); $articles = $query->all(); $data['articles'] = $articles; }elseif($slug == 'dictionary'){ $query = $this->Dictionaries->find() ->where(['Dictionaries.company_id' => $company_data->id]) ->where(['Dictionaries.display_flag' => 1]) ->where(['Dictionaries.delete_flag' => 0]); //->order(['release_date' => 'DESC']) // if(!empty($data['setting']->dictionary_num)){ $limit = $data['setting']->dictionary_num; }else{ $limit = 10; } $query->limit($limit); //件数やページ数のセット if(!empty($page_num)){ $offset = ($limit * $page_num) - $limit; $query->offset($offset); } $count = $query->count(); $dictionaries = $query->all(); $data['dictionaries'] = $dictionaries; //ページネーション if(($count / $limit) > 0 && $count > 0){ $data['pagenation'] = $this->pagenation_data($page_num, $count, $limit); } //ブログや新着情報の一覧の場合 }else{ $query = $this->Pages->find() ->where(['Pages.company_id' => $company_data->id]) ->where(['Pages.parent_id' => $data['page']->id]) ->where(['Pages.pagetype_id' => 6]) ->where(['Pages.display_flag' => 1]) ->where(['Pages.release_date <=' => date('Y-m-d H:i:s')]) ->where(['Pages.delete_flag' => 0]) ->order(['release_date' => 'DESC']); //表示件数 if(!empty($data['page']->other2)){ $limit = $data['page']->other2; }else{ $limit = 10; } //年月アーカイブの場合 if(!empty($archive_year) && !empty($archive_month)){ $query->where(['Pages.release_date LIKE' => $archive_year.'-'.$archive_month.'%']); } //ブログの場合 if($data['page']->pagetype_id == 2){ //カテゴリやタグの絞り込み if($fixed_slug == 'category'){ /*$query->matching('BlogCategories', function($q)use($tag_category) { //return $q->where(['BlogCategories.slug' => $tag_category]); return $q->where(['BlogCategories.name' => urldecode($tag_category)]); });*/ // $data['parent_category'] = $this->BlogCategories->find() ->where(['BlogCategories.company_id' => $company_data->id]) ->where(['BlogCategories.name' => urldecode($tag_category)]) ->first(); $blog_parent_id = $data['parent_category']->id; $query->matching('BlogCategories', function($q)use($blog_parent_id) { //return $q->where(['BlogCategories.slug' => $tag_category]); return $q->where(['BlogCategories.id' => $blog_parent_id]); }); }elseif($fixed_slug == 'tag'){ /*$query->matching('BlogTags', function($q)use($tag_category) { //return $q->where(['BlogCategories.slug' => $tag_category]); return $q->where(['BlogTags.name' => urldecode($tag_category)]); });*/ //Blog用のタグではなく、Page用のタグを用いる $tmp_tag = $this->Tags->find() ->where(['Tags.company_id' => $company_data->id]) ->where(['Tags.name' => urldecode($tag_category)]) ->first(); // /*$query->matching('Tags', function($q)use($tag_category) { //return $q->where(['BlogCategories.slug' => $tag_category]); return $q->where(['Tags.name' => urldecode($tag_category)]); });*/ $tmp_tag_id = $tmp_tag->id; $query->matching('Tags', function($q)use($tmp_tag_id) { //return $q->where(['BlogCategories.slug' => $tag_category]); return $q->where(['Tags.id' => $tmp_tag_id]); }); // $data['parent_tag'] = $this->Tags->find() ->where(['Tags.company_id' => $company_data->id]) ->where(['Tags.name' => urldecode($tag_category)]) ->first(); } //年月アーカイブリンク用のデータ取得 if($data['page']->other3 == 1){ //一番古い記事を取得 $oldest_page = $this->Pages->find() ->where(['Pages.company_id' => $company_data->id]) ->where(['Pages.parent_id' => $data['page']->id]) ->where(['Pages.pagetype_id' => 6]) ->where(['Pages.display_flag' => 1]) ->where(['Pages.release_date <=' => date('Y-m-d H:i:s')]) ->where(['Pages.delete_flag' => 0]) ->order(['release_date' => 'ASC']) ->first(); $data['archives'] = []; if(!empty($oldest_page)){ $oldest_year = $oldest_page->release_date->format('Y'); for($year=date('Y');$year>=$oldest_year;$year--){ $data['archives'][$year] = []; $month_count = 0; for($month=12;$month>=1;$month--){ if($year == date('Y') && $month > date('n')){ }else{ $month_str = sprintf("%02d",$month); $count = 0; if(($count = Cache::read($company_data->id.'_blog_'.$year.'-'.$month_str, 'blog_archive')) === false){ $count = $this->Pages->find() ->where(['Pages.company_id' => $company_data->id]) ->where(['Pages.parent_id' => $data['page']->id]) ->where(['Pages.pagetype_id' => 6]) ->where(['Pages.display_flag' => 1]) //->where(['Pages.release_date <=' => date('Y-m-d H:i:s')]) ->where(['AND' => [['Pages.release_date <=' => date('Y-m-d H:i:s')], ['Pages.release_date LIKE' => $year.'-'.$month_str.'%']]]) ->where(['Pages.delete_flag' => 0]) ->order(['release_date' => 'DESC']) ->count(); //キャッシュの書き込み Cache::write($company_data->id.'_blog_'.$year.'-'.$month_str, $count, 'blog_archive'); } $data['archives'][$year][$month_str] = $count; $month_count = $month_count + $count; } /*if($year == date('Y') && $month_str == date('m')){ break; }*/ } if($month_count == 0){ unset($data['archives'][$year]); } } } } //新着情報の場合 }elseif($data['page']->pagetype_id == 3){ //カテゴリやタグの絞り込み if($fixed_slug == 'category'){ /*$query->matching('NewsCategories', function($q)use($tag_category) { //return $q->where(['NewsCategories.slug' => $tag_category]); return $q->where(['NewsCategories.name' => urldecode($tag_category)]); });*/ // $data['parent_category'] = $this->NewsCategories->find() ->where(['NewsCategories.company_id' => $company_data->id]) ->where(['NewsCategories.name' => urldecode($tag_category)]) ->first(); $news_parent_id = $data['parent_category']->id; $query->matching('NewsCategories', function($q)use($news_parent_id) { //return $q->where(['NewsCategories.slug' => $tag_category]); return $q->where(['NewsCategories.id' => $news_parent_id]); }); } //年月アーカイブリンク用のデータ取得 if($data['page']->other3 == 1){ //一番古い記事を取得 $oldest_page = $this->Pages->find() ->where(['Pages.company_id' => $company_data->id]) ->where(['Pages.parent_id' => $data['page']->id]) ->where(['Pages.pagetype_id' => 6]) ->where(['Pages.display_flag' => 1]) ->where(['Pages.release_date <=' => date('Y-m-d H:i:s')]) ->where(['Pages.delete_flag' => 0]) ->order(['release_date' => 'ASC']) ->first(); $data['archives'] = []; if(!empty($oldest_page)){ $oldest_year = $oldest_page->release_date->format('Y'); for($year=date('Y');$year>=$oldest_year;$year--){ $data['archives'][$year] = []; $month_count = 0; for($month=12;$month>=1;$month--){ if($year == date('Y') && $month > date('n')){ }else{ $month_str = sprintf("%02d",$month); $count = 0; if(($count = Cache::read($company_data->id.'_news_'.$year.'-'.$month_str, 'news_archive')) === false){ $count = $this->Pages->find() ->where(['Pages.company_id' => $company_data->id]) ->where(['Pages.parent_id' => $data['page']->id]) ->where(['Pages.pagetype_id' => 6]) ->where(['Pages.display_flag' => 1]) //->where(['Pages.release_date <=' => date('Y-m-d H:i:s')]) ->where(['AND' => [['Pages.release_date <=' => date('Y-m-d H:i:s')], ['Pages.release_date LIKE' => $year.'-'.$month_str.'%']]]) ->where(['Pages.delete_flag' => 0]) ->order(['release_date' => 'DESC']) ->count(); //キャッシュの書き込み Cache::write($company_data->id.'_news_'.$year.'-'.$month_str, $count, 'news_archive'); } $data['archives'][$year][$month_str] = $count; $month_count = $month_count + $count; } if($year == date('Y') && $month_str == date('m')){ break; } } if($month_count == 0){ unset($data['archives'][$year]); } } } } //コラムの場合 }elseif($data['page']->pagetype_id == 5){ //カテゴリやタグの絞り込み if($fixed_slug == 'category'){ /*$query->matching('ColumnCategories', function($q)use($tag_category) { //return $q->where(['ColumnCategories.slug' => $tag_category]); return $q->where(['ColumnCategories.name' => urldecode($tag_category)]); });*/ // $data['parent_category'] = $this->ColumnCategories->find() ->where(['ColumnCategories.company_id' => $company_data->id]) ->where(['ColumnCategories.name' => urldecode($tag_category)]) ->first(); $column_parent_id = $data['parent_category']->id; $query->matching('ColumnCategories', function($q)use($column_parent_id) { //return $q->where(['ColumnCategories.slug' => $tag_category]); return $q->where(['ColumnCategories.id' => $column_parent_id]); }); }elseif($fixed_slug == 'tag'){ /*$query->matching('ColumnTags', function($q)use($tag_category) { //return $q->where(['ColumnCategories.slug' => $tag_category]); return $q->where(['ColumnTags.name' => urldecode($tag_category)]); });*/ //Column用のタグではなく、Page用のタグを用いる $tmp_tag = $this->Tags->find() ->where(['Tags.company_id' => $company_data->id]) ->where(['Tags.name' => urldecode($tag_category)]) ->first(); // /*$query->matching('Tags', function($q)use($tag_category) { //return $q->where(['ColumnCategories.slug' => $tag_category]); return $q->where(['Tags.name' => urldecode($tag_category)]); });*/ $tmp_tag_id = $tmp_tag->id; $query->matching('Tags', function($q)use($tmp_tag_id) { //return $q->where(['ColumnCategories.slug' => $tag_category]); return $q->where(['Tags.id' => $tmp_tag_id]); }); // $data['parent_tag'] = $this->Tags->find() ->where(['Tags.company_id' => $company_data->id]) ->where(['Tags.name' => urldecode($tag_category)]) ->first(); } //年月アーカイブリンク用のデータ取得 if($data['page']->other3 == 1){ //一番古い記事を取得 $oldest_page = $this->Pages->find() ->where(['Pages.company_id' => $company_data->id]) ->where(['Pages.parent_id' => $data['page']->id]) ->where(['Pages.pagetype_id' => 6]) ->where(['Pages.display_flag' => 1]) ->where(['Pages.release_date <=' => date('Y-m-d H:i:s')]) ->where(['Pages.delete_flag' => 0]) ->order(['release_date' => 'ASC']) ->first(); $data['archives'] = []; if(!empty($oldest_page)){ $oldest_year = $oldest_page->release_date->format('Y'); for($year=date('Y');$year>=$oldest_year;$year--){ $data['archives'][$year] = []; $month_count = 0; for($month=12;$month>=1;$month--){ if($year == date('Y') && $month > date('n')){ }else{ $month_str = sprintf("%02d",$month); $count = 0; if(($count = Cache::read($company_data->id.'_column_'.$year.'-'.$month_str, 'column_archive')) === false){ $count = $this->Pages->find() ->where(['Pages.company_id' => $company_data->id]) ->where(['Pages.parent_id' => $data['page']->id]) ->where(['Pages.pagetype_id' => 6]) ->where(['Pages.display_flag' => 1]) //->where(['Pages.release_date <=' => date('Y-m-d H:i:s')]) ->where(['AND' => [['Pages.release_date <=' => date('Y-m-d H:i:s')], ['Pages.release_date LIKE' => $year.'-'.$month_str.'%']]]) ->where(['Pages.delete_flag' => 0]) ->order(['release_date' => 'DESC']) ->count(); //キャッシュの書き込み Cache::write($company_data->id.'_column_'.$year.'-'.$month_str, $count, 'column_archive'); } $data['archives'][$year][$month_str] = $count; $month_count = $month_count + $count; } /*if($year == date('Y') && $month_str == date('m')){ break; }*/ } if($month_count == 0){ unset($data['archives'][$year]); } } } } //マルチギャラリーの場合 }elseif($data['page']->pagetype_id == 12){ //カテゴリやタグの絞り込み if($fixed_slug == 'category'){ /*$query->matching('MultigalleryCategories', function($q)use($tag_category) { //return $q->where(['MultigalleryCategories.slug' => $tag_category]); return $q->where(['MultigalleryCategories.name' => urldecode($tag_category)]); });*/ // $data['parent_category'] = $this->MultigalleryCategories->find() ->where(['MultigalleryCategories.company_id' => $company_data->id]) ->where(['MultigalleryCategories.name' => urldecode($tag_category)]) ->first(); $multigallery_parent_id = $data['parent_category']->id; $query->matching('MultigalleryCategories', function($q)use($multigallery_parent_id) { //return $q->where(['MultigalleryCategories.slug' => $tag_category]); return $q->where(['MultigalleryCategories.id' => $multigallery_parent_id]); }); }elseif($fixed_slug == 'tag'){ /*$query->matching('MultigalleryTags', function($q)use($tag_category) { //return $q->where(['MultigalleryCategories.slug' => $tag_category]); return $q->where(['MultigalleryTags.name' => urldecode($tag_category)]); });*/ //Multigallery用のタグではなく、Page用のタグを用いる $tmp_tag = $this->Tags->find() ->where(['Tags.company_id' => $company_data->id]) ->where(['Tags.name' => urldecode($tag_category)]) ->first(); // /*$query->matching('Tags', function($q)use($tag_category) { //return $q->where(['MultigalleryCategories.slug' => $tag_category]); return $q->where(['Tags.name' => urldecode($tag_category)]); });*/ $tmp_tag_id = $tmp_tag->id; $query->matching('Tags', function($q)use($tmp_tag_id) { //return $q->where(['MultigalleryCategories.slug' => $tag_category]); return $q->where(['Tags.id' => $tmp_tag_id]); }); // $data['parent_tag'] = $this->Tags->find() ->where(['Tags.company_id' => $company_data->id]) ->where(['Tags.name' => urldecode($tag_category)]) ->first(); } //年月アーカイブリンク用のデータ取得 if($data['page']->other3 == 1){ //一番古い記事を取得 $oldest_page = $this->Pages->find() ->where(['Pages.company_id' => $company_data->id]) ->where(['Pages.parent_id' => $data['page']->id]) ->where(['Pages.pagetype_id' => 6]) ->where(['Pages.display_flag' => 1]) ->where(['Pages.release_date <=' => date('Y-m-d H:i:s')]) ->where(['Pages.delete_flag' => 0]) ->order(['release_date' => 'ASC']) ->first(); $data['archives'] = []; if(!empty($oldest_page)){ $oldest_year = $oldest_page->release_date->format('Y'); for($year=date('Y');$year>=$oldest_year;$year--){ $data['archives'][$year] = []; $month_count = 0; for($month=12;$month>=1;$month--){ if($year == date('Y') && $month > date('n')){ }else{ $month_str = sprintf("%02d",$month); $count = 0; if(($count = Cache::read($company_data->id.'_multigallery_'.$year.'-'.$month_str, 'multigallery_archive')) === false){ $count = $this->Pages->find() ->where(['Pages.company_id' => $company_data->id]) ->where(['Pages.parent_id' => $data['page']->id]) ->where(['Pages.pagetype_id' => 6]) ->where(['Pages.display_flag' => 1]) //->where(['Pages.release_date <=' => date('Y-m-d H:i:s')]) ->where(['AND' => [['Pages.release_date <=' => date('Y-m-d H:i:s')], ['Pages.release_date LIKE' => $year.'-'.$month_str.'%']]]) ->where(['Pages.delete_flag' => 0]) ->order(['release_date' => 'DESC']) ->count(); //キャッシュの書き込み Cache::write($company_data->id.'_multigallery_'.$year.'-'.$month_str, $count, 'multigallery_archive'); } $data['archives'][$year][$month_str] = $count; $month_count = $month_count + $count; } /*if($year == date('Y') && $month_str == date('m')){ break; }*/ } if($month_count == 0){ unset($data['archives'][$year]); } } } } //特集の場合 /*}elseif($data['page']->pagetype_id == 5){ if(!empty($data['setting']->feature_num)){ $limit = $data['setting']->feature_num; }else{ $limit = 10; } //カテゴリやタグの絞り込み if($fixed_slug == 'category'){ $query->matching('FeatureCategories', function($q)use($tag_category) { //return $q->where(['BlogCategories.slug' => $tag_category]); return $q->where(['FeatureCategories.name' => urldecode($tag_category)]); }); }elseif($fixed_slug == 'tag'){ $query->matching('FeatureTags', function($q)use($tag_category) { //return $q->where(['BlogCategories.slug' => $tag_category]); return $q->where(['FeatureTags.name' => urldecode($tag_category)]); }); }*/ }else{ $limit = 10; } $query->limit($limit); //件数やページ数のセット if(!empty($page_num)){ $offset = ($limit * $page_num) - $limit; $query->offset($offset); } //カテゴリやタグの絞り込み /* if($fixed_slug == 'category'){ $article_category = urldecode($tag_category); if($data['page']->pagetype_id == 2){ $query->matching('BlogCategories', function($q)use($tag_category) { //return $q->where(['BlogCategories.slug' => $tag_category]); return $q->where(['BlogCategories.name' => urldecode($tag_category)]); }); }elseif($data['page']->pagetype_id == 3){ $query->matching('NewsCategories', function($q)use($tag_category) { //return $q->where(['NewsCategories.slug' => $tag_category]); return $q->where(['NewsCategories.name' => urldecode($tag_category)]); }); } }elseif($fixed_slug == 'tag'){ $article_tag = urldecode($tag_category); $query->matching('BlogTags', function($q)use($tag_category) { //return $q->where(['BlogCategories.slug' => $tag_category]); return $q->where(['BlogTags.name' => urldecode($tag_category)]); }); }*/ $count = $query->count(); $articles = $query->all(); $data['articles'] = $articles; //ページネーション if(($count / $limit) > 0 && $count > 0){ $data['pagenation'] = $this->pagenation_data($page_num, $count, $limit); } } } //キャッシュの確認(アーカイブ・カテゴリ・タグ・記事ページの場合、カテゴリデータ・最近の投稿・アーカイブを取得) if(($fixed_slug == 'archive' || $fixed_slug == 'category' || $fixed_slug == 'tag' || $fixed_slug == 'detail' || $fixed_slug2 == 'detail') || ($data['page']->pagetype_id == 2 || $data['page']->pagetype_id == 3 || $data['page']->pagetype_id == 5 || $data['page']->pagetype_id == 12)){ //固定ページ用のタグに紐付く一覧の場合 if($slug == 'page'){ $data['tags'] = $this->Tags->find() ->where(['Tags.company_id' => $company_data->id]) //->where(['BlogTags.blog_id' => $tmp_page_id]) ->where(['Tags.display_flag' => 1]) ->where(['Tags.delete_flag' => 0]) ->order(['sort' => 'ASC']) ->all(); //ブログや新着情報の一覧の場合 }else{ if($data['page']->pagetype_id == 6){ $parent_id = $data['page']->parent_id; $tmp_page = $this->Pages->find() ->where(['Pages.company_id' => $company_data->id]) ->where(['Pages.id' => $parent_id]) ->first(); $tmp_page_id = $tmp_page->id; $tmp_pagetype_id = $tmp_page->pagetype_id; }else{ $tmp_page_id = $data['page']->id; $tmp_pagetype_id = $data['page']->pagetype_id; } //ブログ if($tmp_pagetype_id == 2){ $data['categories'] = $this->BlogCategories->find() ->where(['BlogCategories.company_id' => $company_data->id]) ->where(['BlogCategories.blog_id' => $tmp_page_id]) ->where(['BlogCategories.display_flag' => 1]) ->where(['BlogCategories.delete_flag' => 0]) ->order(['sort' => 'ASC']) ->all(); /*$data['tags'] = $this->BlogTags->find() ->where(['BlogTags.company_id' => $company_data->id]) //->where(['BlogTags.blog_id' => $tmp_page_id]) ->where(['BlogTags.display_flag' => 1]) ->where(['BlogTags.delete_flag' => 0]) ->order(['sort' => 'ASC']) ->all();*/ $data['tags'] = $this->Tags->find() ->where(['Tags.company_id' => $company_data->id]) //->where(['Tags.blog_id' => $tmp_page_id]) ->where(['Tags.display_flag' => 1]) ->where(['Tags.delete_flag' => 0]) ->order(['sort' => 'ASC']) ->all(); $data['next_page'] = $this->Pages->find() ->select(['Pages.id', 'Pages.slug', 'Pages.name']) ->where(['Pages.company_id' => $company_data->id]) ->where(['Pages.parent_id' => $data['page']->parent_id]) ->where(['Pages.pagetype_id' => 6, 'AND' => [['Pages.release_date >=' => $data['page']->release_date], ['Pages.release_date <=' => date('Y-m-d H:i:s')]]]) //->where(['Pages.id' => $data['page']->id]) ->where(['NOT' => ['Pages.id' => $data['page']->id]]) //->where(['Pages.release_date >=' => $data['page']->release_date]) ->where(['Pages.display_flag' => 1]) //->order(['release_date' => 'ASC', 'id' => 'DESC']) ->order(['release_date' => 'ASC']) ->first(); $data['prev_page'] = $this->Pages->find() ->select(['Pages.id', 'Pages.slug', 'Pages.name']) ->where(['Pages.company_id' => $company_data->id]) ->where(['Pages.parent_id' => $data['page']->parent_id]) ->where(['Pages.pagetype_id' => 6, 'AND' => [['Pages.release_date <=' => $data['page']->release_date], ['Pages.release_date <=' => date('Y-m-d H:i:s')]]]) //->where(['Pages.id' => $data['page']->id]) ->where(['NOT' => ['Pages.id' => $data['page']->id]]) //->where(['Pages.release_date <=' => $data['page']->release_date]) ->where(['Pages.display_flag' => 1]) //->order(['id' => 'DESC', 'release_date' => 'DESC']) ->order(['release_date' => 'DESC']) ->first(); //新着情報 }elseif($tmp_pagetype_id == 3){ $data['categories'] = $this->NewsCategories->find() ->where(['NewsCategories.company_id' => $company_data->id]) ->where(['NewsCategories.news_id' => $tmp_page_id]) ->where(['NewsCategories.display_flag' => 1]) ->where(['NewsCategories.delete_flag' => 0]) ->order(['sort' => 'ASC']) ->all(); $data['next_page'] = $this->Pages->find() ->select(['Pages.id', 'Pages.slug', 'Pages.name']) ->where(['Pages.company_id' => $company_data->id]) ->where(['Pages.parent_id' => $data['page']->parent_id]) ->where(['Pages.pagetype_id' => 6]) //->where(['Pages.id' => $data['page']->id]) ->where(['NOT' => ['Pages.id' => $data['page']->id]]) ->where(['Pages.release_date >=' => $data['page']->release_date]) ->where(['Pages.display_flag' => 1]) ->order(['release_date' => 'ASC']) ->first(); $data['prev_page'] = $this->Pages->find() ->select(['Pages.id', 'Pages.slug', 'Pages.name']) ->where(['Pages.company_id' => $company_data->id]) ->where(['Pages.parent_id' => $data['page']->parent_id]) ->where(['Pages.pagetype_id' => 6]) //->where(['Pages.id' => $data['page']->id]) ->where(['NOT' => ['Pages.id' => $data['page']->id]]) ->where(['Pages.release_date <=' => $data['page']->release_date]) ->where(['Pages.display_flag' => 1]) ->order(['release_date' => 'DESC']) ->first(); //コラム }elseif($tmp_pagetype_id == 5){ $data['categories'] = $this->ColumnCategories->find() ->where(['ColumnCategories.company_id' => $company_data->id]) ->where(['ColumnCategories.column_id' => $tmp_page_id]) ->where(['ColumnCategories.display_flag' => 1]) ->where(['ColumnCategories.delete_flag' => 0]) ->order(['sort' => 'ASC']) ->all(); /*$data['tags'] = $this->ColumnTags->find() ->where(['ColumnTags.company_id' => $company_data->id]) //->where(['ColumnTags.column_id' => $tmp_page_id]) ->where(['ColumnTags.display_flag' => 1]) ->where(['ColumnTags.delete_flag' => 0]) ->order(['sort' => 'ASC']) ->all();*/ $data['tags'] = $this->Tags->find() ->where(['Tags.company_id' => $company_data->id]) //->where(['Tags.column_id' => $tmp_page_id]) ->where(['Tags.display_flag' => 1]) ->where(['Tags.delete_flag' => 0]) ->order(['sort' => 'ASC']) ->all(); $data['next_page'] = $this->Pages->find() ->select(['Pages.id', 'Pages.slug', 'Pages.name']) ->where(['Pages.company_id' => $company_data->id]) ->where(['Pages.parent_id' => $data['page']->parent_id]) ->where(['Pages.pagetype_id' => 6, 'AND' => [['Pages.release_date >=' => $data['page']->release_date], ['Pages.release_date <=' => date('Y-m-d H:i:s')]]]) //->where(['Pages.id' => $data['page']->id]) ->where(['NOT' => ['Pages.id' => $data['page']->id]]) //->where(['Pages.release_date >=' => $data['page']->release_date]) ->where(['Pages.display_flag' => 1]) //->order(['release_date' => 'ASC', 'id' => 'DESC']) ->order(['release_date' => 'ASC']) ->first(); $data['prev_page'] = $this->Pages->find() ->select(['Pages.id', 'Pages.slug', 'Pages.name']) ->where(['Pages.company_id' => $company_data->id]) ->where(['Pages.parent_id' => $data['page']->parent_id]) ->where(['Pages.pagetype_id' => 6, 'AND' => [['Pages.release_date <=' => $data['page']->release_date], ['Pages.release_date <=' => date('Y-m-d H:i:s')]]]) //->where(['Pages.id' => $data['page']->id]) ->where(['NOT' => ['Pages.id' => $data['page']->id]]) //->where(['Pages.release_date <=' => $data['page']->release_date]) ->where(['Pages.display_flag' => 1]) //->order(['id' => 'DESC', 'release_date' => 'DESC']) ->order(['release_date' => 'DESC']) ->first(); //マルチギャラリー }elseif($tmp_pagetype_id == 12){ $data['categories'] = $this->MultigalleryCategories->find() ->where(['MultigalleryCategories.company_id' => $company_data->id]) ->where(['MultigalleryCategories.multigallery_id' => $tmp_page_id]) ->where(['MultigalleryCategories.display_flag' => 1]) ->where(['MultigalleryCategories.delete_flag' => 0]) ->order(['sort' => 'ASC']) ->all(); /*$data['tags'] = $this->MultigalleryTags->find() ->where(['MultigalleryTags.company_id' => $company_data->id]) //->where(['MultigalleryTags.multigallery_id' => $tmp_page_id]) ->where(['MultigalleryTags.display_flag' => 1]) ->where(['MultigalleryTags.delete_flag' => 0]) ->order(['sort' => 'ASC']) ->all();*/ $data['tags'] = $this->Tags->find() ->where(['Tags.company_id' => $company_data->id]) //->where(['Tags.multigallery_id' => $tmp_page_id]) ->where(['Tags.display_flag' => 1]) ->where(['Tags.delete_flag' => 0]) ->order(['sort' => 'ASC']) ->all(); $data['next_page'] = $this->Pages->find() ->select(['Pages.id', 'Pages.slug', 'Pages.name']) ->where(['Pages.company_id' => $company_data->id]) ->where(['Pages.parent_id' => $data['page']->parent_id]) ->where(['Pages.pagetype_id' => 6, 'AND' => [['Pages.release_date >=' => $data['page']->release_date], ['Pages.release_date <=' => date('Y-m-d H:i:s')]]]) //->where(['Pages.id' => $data['page']->id]) ->where(['NOT' => ['Pages.id' => $data['page']->id]]) //->where(['Pages.release_date >=' => $data['page']->release_date]) ->where(['Pages.display_flag' => 1]) //->order(['release_date' => 'ASC', 'id' => 'DESC']) ->order(['release_date' => 'ASC']) ->first(); $data['prev_page'] = $this->Pages->find() ->select(['Pages.id', 'Pages.slug', 'Pages.name']) ->where(['Pages.company_id' => $company_data->id]) ->where(['Pages.parent_id' => $data['page']->parent_id]) ->where(['Pages.pagetype_id' => 6, 'AND' => [['Pages.release_date <=' => $data['page']->release_date], ['Pages.release_date <=' => date('Y-m-d H:i:s')]]]) //->where(['Pages.id' => $data['page']->id]) ->where(['NOT' => ['Pages.id' => $data['page']->id]]) //->where(['Pages.release_date <=' => $data['page']->release_date]) ->where(['Pages.display_flag' => 1]) //->order(['id' => 'DESC', 'release_date' => 'DESC']) ->order(['release_date' => 'DESC']) ->first(); //特集 /*}elseif($tmp_pagetype_id == 5){ $data['categories'] = $this->FeatureCategories->find() ->where(['FeatureCategories.company_id' => $company_data->id]) ->where(['FeatureCategories.feature_id' => $tmp_page_id]) ->where(['FeatureCategories.display_flag' => 1]) ->where(['FeatureCategories.delete_flag' => 0]) ->order(['sort' => 'ASC']) ->all(); $data['tags'] = $this->FeatureTags->find() ->where(['FeatureTags.company_id' => $company_data->id]) //->where(['BlogTags.blog_id' => $tmp_page_id]) ->where(['FeatureTags.display_flag' => 1]) ->where(['FeatureTags.delete_flag' => 0]) ->order(['sort' => 'ASC']) ->all();*/ } $data['resent_posts'] = $this->Pages->find() ->where(['Pages.company_id' => $company_data->id]) ->where(['Pages.parent_id' => $tmp_page_id]) ->where(['Pages.pagetype_id' => 6]) ->where(['Pages.display_flag' => 1]) ->where(['Pages.delete_flag' => 0]) ->where(['Pages.release_date <=' => date('Y-m-d H:i:s')]) ->order(['release_date' => 'DESC']) ->limit(3) ->all(); } } //キャッシュの確認(記事ページの場合、親データを取得) //if(isset($fixed_slug) && ($fixed_slug == 'detail')){ if(isset($fixed_slug) && ($fixed_slug == 'detail' || $fixed_slug2 == 'detail') && $data['page']->pagetype_id == 6){ $data['parent_page'] = $this->Pages->find() ->where(['Pages.company_id' => $company_data->id]) ->where(['Pages.id' => $data['page']->parent_id]) ->where(['Pages.display_flag' => 1]) ->where(['Pages.delete_flag' => 0]) ->order(['release_date' => 'DESC']) ->first(); //記事ページのタイトル if($data['parent_page']->other4 == 1){ $data['page']->title = $data['page']->title.' | '.$data['parent_page']->title; } //サブナビゲーション if(!empty($data['parent_page']->navigation_id)){ $navigation_data = $this->Navigations->find() ->where(['Navigations.id' => $data['parent_page']->navigation_id]) ->where(['Navigations.company_id' => $company_data->id]) ->where(['Navigations.delete_flag' => 0]) ->first(); // $navigation_page_id = $data['parent_page']->navigation_id; $data['page']->navigation_id = $data['parent_page']->navigation_id; $data['page']->h_d_flag = $data['parent_page']->h_d_flag; $data['page']->h_d_logo_flag = $data['parent_page']->h_d_logo_flag; $data['page']->h_d_navi_flag = $data['parent_page']->h_d_navi_flag; $data['page']->h_d_mv_flag = $data['parent_page']->h_d_mv_flag; $data['page']->f_d_flag = $data['parent_page']->f_d_flag; $data['page']->f_d_logo_flag = $data['parent_page']->f_d_logo_flag; $data['page']->f_d_navi_flag = $data['parent_page']->f_d_navi_flag; $data['page']->f_d_sns_flag = $data['parent_page']->f_d_sns_flag; // $data['setting']->loading_image = $navigation_data->loading_image; $data['setting']->common_tel = $navigation_data->common_tel; $data['setting']->common_address = $navigation_data->common_address; $data['setting']->common_hour = $navigation_data->common_hour; $data['setting']->logo_image = $navigation_data->logo_image; $data['setting']->header_logo_link = $navigation_data->header_logo_link; $data['setting']->translate_flag = $navigation_data->translate_flag; $data['setting']->h_tel_flag = $navigation_data->h_tel_flag; $data['setting']->h_address_flag = $navigation_data->h_address_flag; $data['setting']->h_hour_flag = $navigation_data->h_hour_flag; $data['setting']->h_button_flag = $navigation_data->h_button_flag; $data['setting']->header_link_type = $navigation_data->header_link_type; $data['setting']->header_link = $navigation_data->header_link; $data['setting']->header_text = $navigation_data->header_text; $data['setting']->header_link_target = $navigation_data->header_link_target; $data['setting']->text_align_flag = $navigation_data->text_align_flag; $data['setting']->footer_image = $navigation_data->footer_image; $data['setting']->footer_logo_link = $navigation_data->footer_logo_link; $data['setting']->footer_flag = $navigation_data->footer_flag; $data['setting']->f_tel_flag = $navigation_data->f_tel_flag; $data['setting']->f_hour_flag = $navigation_data->f_hour_flag; $data['setting']->f_button_flag = $navigation_data->f_button_flag; $data['setting']->footer_link_type = $navigation_data->footer_link_type; $data['setting']->footer_link = $navigation_data->footer_link; $data['setting']->footer_text = $navigation_data->footer_text; $data['setting']->footer_link_target = $navigation_data->footer_link_target; $data['setting']->mystyle_css = $navigation_data->mystyle_css; $data['setting']->css_font = $navigation_data->css_font; } //年月アーカイブリンク用のデータ取得 //一番古い記事を取得 $oldest_page = $this->Pages->find() ->where(['Pages.company_id' => $company_data->id]) ->where(['Pages.parent_id' => $data['parent_page']->id]) ->where(['Pages.pagetype_id' => 6]) ->where(['Pages.display_flag' => 1]) ->where(['Pages.release_date <=' => date('Y-m-d H:i:s')]) ->where(['Pages.delete_flag' => 0]) ->order(['release_date' => 'ASC']) ->first(); $data['archives'] = []; if(!empty($oldest_page)){ $oldest_year = $oldest_page->release_date->format('Y'); for($year=date('Y');$year>=$oldest_year;$year--){ $data['archives'][$year] = []; $month_count = 0; for($month=12;$month>=1;$month--){ $month_str = sprintf("%02d",$month); $count = 0; $count = $this->Pages->find() ->where(['Pages.company_id' => $company_data->id]) ->where(['Pages.parent_id' => $data['parent_page']->id]) ->where(['Pages.pagetype_id' => 6]) ->where(['Pages.display_flag' => 1]) //->where(['Pages.release_date <=' => date('Y-m-d H:i:s')]) ->where(['AND' => [['Pages.release_date <=' => date('Y-m-d H:i:s')], ['Pages.release_date LIKE' => $year.'-'.$month_str.'%']]]) ->where(['Pages.delete_flag' => 0]) ->order(['release_date' => 'DESC']) ->count(); $data['archives'][$year][$month_str] = $count; $month_count = $month_count + $count; if($year == date('Y') && $month_str == date('m')){ break; } } if($month_count == 0){ unset($data['archives'][$year]); } } } //前後の記事データの取得 /*$data['prev_page'] = $this->Pages->find() //->where(['Pages.id IS NOT' => $data['page']->id]) ->where(['Pages.company_id' => $company_data->id]) ->where(['Pages.pagetype_id' => 6]) ->where(['Pages.release_date <' => $data['page']->release_date]) ->where(['Pages.display_flag' => 1]) ->where(['Pages.delete_flag' => 0]) ->order(['release_date' => 'DESC']) ->first(); $data['next_page'] = $this->Pages->find() //->where(['Pages.id IS NOT' => $data['page']->id]) ->where(['Pages.company_id' => $company_data->id]) ->where(['Pages.pagetype_id' => 6]) ->where(['Pages.release_date >' => $data['page']->release_date]) ->where(['Pages.display_flag' => 1]) ->where(['Pages.delete_flag' => 0]) ->order(['release_date' => 'DESC']) ->first();*/ }else{ $data['parent_page'] = $data['page']; } } //gallery_archive 関連データ //if($page_mode == 'gallery_archive'){ if($page_mode == 'gallery_archive' || (isset($data['page']->pagetype_id) && $data['page']->pagetype_id == '8')){ //後から追加した機能、ギャラリーの枠として使用されているページのデータ取得 $tmp_reference_page_query = $this->Pages->find() ->where(['Pages.company_id' => $company_data->id]) ->where(['Pages.pagetype_id' => 8]) ->where(['Pages.delete_flag' => 0]); //->first(); if(!empty($data['page']->page_kind)){ $tmp_reference_page_query->where(['Pages.page_kind' => $data['page']->page_kind]); }else{ $tmp_reference_page_query->where(['OR' => [['Pages.page_kind' => ''], ['Pages.page_kind IS NULL']]]); } $tmp_reference_page = $tmp_reference_page_query->first(); //カテゴリ分け表示、一括表示の分岐 //一括表示の場合 //if($slug == 'all'){ if($slug == 'all'){ //全カテゴリカテゴリのデータ取得 $query = $this->Galleries->find() ->contain(['GalleryCategories']) ->where(['Galleries.company_id' => $company_data->id]) //->where(['Galleries.gallery_category_id IN' => $category_id_array]) ->where(['Galleries.display_flag' => 1]) ->where(['Galleries.delete_flag' => 0]) //gallery_archiveの暫定対策 ->where(['GalleryCategories.gallery_kind IS NULL']); //->order(['Galleries.sort' => 'ASC']); //->order(['GalleryCategories.sort' => 'ASC', 'Galleries.sort' => 'ASC']); if($tmp_reference_page->sort_flag == 1){ //$query->order(['GalleryCategories.sort' => 'ASC', 'Galleries.sort' => 'DESC']); $query->order(['Galleries.sort' => 'DESC']); }else{ //$query->order(['GalleryCategories.sort' => 'ASC', 'Galleries.sort' => 'ASC']); $query->order(['Galleries.sort' => 'ASC']); } //->order(['release_date' => 'DESC']) // if(isset($data['setting']->gallery_archive_title) && !empty($data['setting']->gallery_archive_title)){ $slug == $data['setting']->gallery_archive_title; $data['gallery_category'] = new \stdClass; $data['gallery_category']->name = $data['setting']->gallery_archive_title; //$data['gallery_category']->abbr = $data['setting']->gallery_archive_title; }else{ $slug == '全てを表示'; $data['gallery_category'] = new \stdClass; $data['gallery_category']->name = '全てを表示'; //$data['gallery_category']->abbr = '全てを表示'; } //カテゴリ一覧 $data['gallery_categories'] = $this->GalleryCategories->find() ->select(['GalleryCategories.name', 'GalleryCategories.abbr']) ->where(['GalleryCategories.company_id' => $company_data->id]) ->where(['GalleryCategories.display_flag' => 1]) ->where(['GalleryCategories.delete_flag' => 0]) ->order(['GalleryCategories.sort' => 'ASC']) //gallery_archiveの暫定対策 ->where(['GalleryCategories.gallery_kind IS NULL']) ->all(); // //$data['tmp_layer'] = '/'.$slug.'/gallery_archive/'; //$data['tmp_layer'] = '/gallery_archive/'; $data['tmp_layer'] = '/gallery_archive/all/'; //後から追加した機能、ギャラリーの枠として }elseif($data['page']->pagetype_id == '8' && ($page_mode != 'gallery_archive' || $fixed_slug == 'detail')){ //詳細 if($fixed_slug == 'detail'){ $data['gallery'] = $this->Galleries->find() ->contain(['GalleryCategories']) ->where(['Galleries.id' => $tag_category]) ->where(['Galleries.company_id' => $company_data->id]) ->where(['Galleries.display_flag' => 1]) ->where(['Galleries.delete_flag' => 0]) ->first(); if(!empty($data['gallery'])){ if(isset($data['breadcrumb'][2]['url']) && !empty($data['breadcrumb'][2]['url'])){ $data['breadcrumb'][3]['url'] = ''; $data['breadcrumb'][3]['name'] = $data['gallery']->name; }else{ $data['breadcrumb'][2]['url'] = ''; $data['breadcrumb'][2]['name'] = $data['gallery']->name; } //prev /*$prev_query = $this->Galleries->find() ->contain(['GalleryCategories']) ->select(['Galleries.id', 'prev_id' => $query->func()->max('Galleries.sort')]) ->where(['Galleries.company_id' => $company_data->id]) ->where(['Galleries.sort <' => $data['gallery']->sort]) ->where(['Galleries.display_flag' => 1]) ->where(['Galleries.delete_flag' => 0]); //->order(['Galleries.sort' => 'DESC']) if($tmp_reference_page->sort_flag == 1){ $prev_query->order(['GalleryCategories.sort' => 'ASC', 'Galleries.sort' => 'DESC']); }else{ $prev_query->order(['GalleryCategories.sort' => 'ASC', 'Galleries.sort' => 'ASC']); } //->first(); //ギャラリー複数化 if(!empty($data['page']->page_kind)){ $prev_query->where(['Galleries.gallery_kind' => $data['page']->page_kind]); }else{ $prev_query->where(['OR' => [['Galleries.gallery_kind' => ''], ['Galleries.gallery_kind IS NULL']]]); } $data['prev_gallery'] = $prev_query->first(); //next $next_query = $this->Galleries->find() ->contain(['GalleryCategories']) ->select(['Galleries.id', 'next_id' => $query->func()->min('Galleries.sort')]) ->where(['Galleries.company_id' => $company_data->id]) ->where(['Galleries.sort >' => $data['gallery']->sort]) ->where(['Galleries.display_flag' => 1]) ->where(['Galleries.delete_flag' => 0]); if($tmp_reference_page->sort_flag == 1){ $next_query->order(['GalleryCategories.sort' => 'ASC', 'Galleries.sort' => 'ASC']); }else{ $next_query->order(['GalleryCategories.sort' => 'ASC', 'Galleries.sort' => 'DESC']); } //->order(['Galleries.sort' => 'ASC']) //->first(); //ギャラリー複数化 if(!empty($data['page']->page_kind)){ $next_query->where(['Galleries.gallery_kind' => $data['page']->page_kind]); }else{ $next_query->where(['OR' => [['Galleries.gallery_kind' => ''], ['Galleries.gallery_kind IS NULL']]]); } $data['next_gallery'] = $next_query->first();*/ //min_sort $min_sort = $this->Galleries->find() ->contain(['GalleryCategories']) ->select(['min_sort' => $query->func()->min('Galleries.sort')]) ->where(['Galleries.company_id' => $company_data->id]) ->where(['Galleries.sort >' => $data['gallery']->sort]) ->where(['Galleries.display_flag' => 1]) ->where(['Galleries.delete_flag' => 0]); //ギャラリー複数化 if(!empty($data['page']->page_kind)){ $min_sort->where(['Galleries.gallery_kind' => $data['page']->page_kind]); }else{ $min_sort->where(['OR' => [['Galleries.gallery_kind' => ''], ['Galleries.gallery_kind IS NULL']]]); } $data['min_sort'] = $min_sort->first(); //max_sort $max_sort = $this->Galleries->find() ->contain(['GalleryCategories']) ->select(['max_sort' => $query->func()->max('Galleries.sort')]) ->where(['Galleries.company_id' => $company_data->id]) ->where(['Galleries.sort <' => $data['gallery']->sort]) ->where(['Galleries.display_flag' => 1]) ->where(['Galleries.delete_flag' => 0]); //ギャラリー複数化 if(!empty($data['page']->page_kind)){ $max_sort->where(['Galleries.gallery_kind' => $data['page']->page_kind]); }else{ $max_sort->where(['OR' => [['Galleries.gallery_kind' => ''], ['Galleries.gallery_kind IS NULL']]]); } $data['max_sort'] = $max_sort->first(); // if($tmp_reference_page->sort_flag == 1){ $prev_sort = $data['min_sort']->min_sort; $next_sort = $data['max_sort']->max_sort; }else{ $prev_sort = $data['max_sort']->max_sort; $next_sort = $data['min_sort']->min_sort; } //prev $prev_gallery = $this->Galleries->find() ->contain(['GalleryCategories']) ->where(['Galleries.company_id' => $company_data->id]) ->where(['Galleries.sort' => $prev_sort]) ->where(['Galleries.display_flag' => 1]) ->where(['Galleries.delete_flag' => 0]); //->first(); //ギャラリー複数化 if(!empty($data['page']->page_kind)){ $prev_gallery->where(['Galleries.gallery_kind' => $data['page']->page_kind]); }else{ $prev_gallery->where(['OR' => [['Galleries.gallery_kind' => ''], ['Galleries.gallery_kind IS NULL']]]); } $data['prev_gallery'] = $prev_gallery->first(); //next $next_gallery = $this->Galleries->find() ->contain(['GalleryCategories']) ->where(['Galleries.company_id' => $company_data->id]) ->where(['Galleries.sort' => $next_sort]) ->where(['Galleries.display_flag' => 1]) ->where(['Galleries.delete_flag' => 0]); //->first(); //ギャラリー複数化 if(!empty($data['page']->page_kind)){ $next_gallery->where(['Galleries.gallery_kind' => $data['page']->page_kind]); }else{ $next_gallery->where(['OR' => [['Galleries.gallery_kind' => ''], ['Galleries.gallery_kind IS NULL']]]); } $data['next_gallery'] = $next_gallery->first(); // if($page_mode == 'gallery_archive'){ if(!empty($data['prev_gallery'])){ $data['tmp_layer_prev'] = '/gallery_archive/detail/'.$data['prev_gallery']->id.'/'; }else{ $data['tmp_layer_prev'] = ''; } if(!empty($data['next_gallery'])){ $data['tmp_layer_next'] = '/gallery_archive/detail/'.$data['next_gallery']->id.'/'; }else{ $data['tmp_layer_next'] = ''; } } }else{ $data['breadcrumb'][2]['url'] = ''; $data['breadcrumb'][2]['name'] = 'NOT FOUND'; $data['gallery'] = new \stdClass; $data['gallery']->name = ''; $data['gallery']->image = ''; $data['gallery']->images = ''; } //全件・もしくはカテゴリ別 }else{ //全カテゴリカテゴリのデータ取得 $query = $this->Galleries->find() ->contain(['GalleryCategories']) ->where(['Galleries.company_id' => $company_data->id]) //->where(['Galleries.gallery_category_id IN' => $category_id_array]) ->where(['Galleries.display_flag' => 1]) ->where(['Galleries.delete_flag' => 0]); //->order(['Galleries.sort' => 'ASC']); //->order(['GalleryCategories.sort' => 'ASC', 'Galleries.sort' => 'ASC']); //->order(['release_date' => 'DESC']) //昇順・降順 if($tmp_reference_page->sort_flag == 1){ //$query->order(['GalleryCategories.sort' => 'ASC', 'Galleries.sort' => 'DESC']); $query->order(['Galleries.sort' => 'DESC']); }else{ //$query->order(['GalleryCategories.sort' => 'ASC', 'Galleries.sort' => 'ASC']); $query->order(['Galleries.sort' => 'ASC']); } //ギャラリー複数化 if(!empty($data['page']->page_kind)){ $query->where(['Galleries.gallery_kind' => $data['page']->page_kind]); }else{ $query->where(['OR' => [['Galleries.gallery_kind' => ''], ['Galleries.gallery_kind IS NULL']]]); } //カテゴリの絞り込み if($fixed_slug == 'category'){ $tmp_gallery_categories_query = $this->GalleryCategories->find() ->select(['GalleryCategories.id']) ->where(['GalleryCategories.company_id' => $company_data->id]) ->where(['GalleryCategories.name' => urldecode($tag_category)]) ->where(['GalleryCategories.display_flag' => 1]) ->where(['GalleryCategories.delete_flag' => 0]); //->first(); //ギャラリー複数化 if(!empty($data['page']->page_kind)){ $tmp_gallery_categories_query->where(['GalleryCategories.gallery_kind' => $data['page']->page_kind]); }else{ $tmp_gallery_categories_query->where(['GalleryCategories.gallery_kind IS NULL']); } $tmp_gallery_categories = $tmp_gallery_categories_query->first(); $query->where(['Galleries.gallery_category_id' => $tmp_gallery_categories->id]); } // if(isset($data['setting']->gallery_archive_title) && !empty($data['setting']->gallery_archive_title)){ $slug == $data['setting']->gallery_archive_title; $data['gallery_category'] = new \stdClass; $data['gallery_category']->name = $data['setting']->gallery_archive_title; //$data['gallery_category']->abbr = $data['setting']->gallery_archive_title; }else{ $slug == '全てを表示'; $data['gallery_category'] = new \stdClass; $data['gallery_category']->name = '全てを表示'; //$data['gallery_category']->abbr = '全てを表示'; } //カテゴリ一覧 $gallery_category_query = $this->GalleryCategories->find() ->select(['GalleryCategories.name', 'GalleryCategories.abbr', 'GalleryCategories.gallery_kind']) ->where(['GalleryCategories.company_id' => $company_data->id]) ->where(['GalleryCategories.display_flag' => 1]) ->where(['GalleryCategories.delete_flag' => 0]) ->order(['GalleryCategories.sort' => 'ASC']); //->all(); //ギャラリー複数化 if(!empty($data['page']->page_kind)){ $gallery_category_query->where(['GalleryCategories.gallery_kind' => $data['page']->page_kind]); }else{ $gallery_category_query->where(['OR' => [['GalleryCategories.gallery_kind' => ''], ['GalleryCategories.gallery_kind IS NULL']]]); } $data['gallery_categories'] = $gallery_category_query->all(); // //$data['tmp_layer'] = $data['page']->slug; } }elseif(is_numeric($slug)){ //カテゴリIDの取得 $tmp_block = $this->Blocks->find() //->select(['Pages.id', 'Pages.pagetype_id', 'Pages.parent_id', 'Pages.name', 'Pages.slug', 'Pages.title', 'Pages.sort', 'Pagetypes.id', 'Pagetypes.name']) //->contain(['BlockDetails']) ->where(['Blocks.id' => $slug]) ->where(['Blocks.company_id' => $company_data->id]) ->where(['Blocks.delete_flag' => 0]) ->first(); if(!empty($tmp_block)){ $data['gallery_category'] = new \stdClass; //$data['gallery_category']->name = $tmp_block->block_name; //$data['gallery_category']->abbr = $tmp_block->block_abbr; $data['gallery_category']->name = $tmp_block->headline; $data['gallery_category']->abbr = $tmp_block->subheadline; }else{ $data['gallery_category'] = new \stdClass; $data['gallery_category']->name = ''; $data['gallery_category']->abbr = ''; } $category_id_array = []; if($tmp_block->tmp_flag == 1){ if(!empty($tmp_block->text1)){ $category_id_array = explode(',', $tmp_block->text1); } }else{ if(!empty($tmp_block->block_details)){ $category_id_array = explode(',', $tmp_block->block_details[0]->content); } } //カテゴリに紐付くデータ取得 $query = $this->Galleries->find() ->contain(['GalleryCategories']) ->where(['Galleries.company_id' => $company_data->id]) ->where(['Galleries.gallery_category_id IN' => $category_id_array]) ->where(['Galleries.display_flag' => 1]) ->where(['Galleries.delete_flag' => 0]); //->order(['Galleries.sort' => 'ASC']); //->order(['GalleryCategories.sort' => 'ASC', 'Galleries.sort' => 'ASC']); if($tmp_reference_page->sort_flag == 1){ $query->order(['GalleryCategories.sort' => 'ASC', 'Galleries.sort' => 'DESC']); }else{ $query->order(['GalleryCategories.sort' => 'ASC', 'Galleries.sort' => 'ASC']); } //->order(['release_date' => 'DESC']) //カテゴリ一覧 //$data['gallery_categories'] = ''; // //$data['tmp_layer'] = '/'.$slug.'/gallery_archive/'; $data['tmp_layer'] = '/gallery_archive/'.$slug.'/'; //全カテゴリ表示の場合 }elseif($slug == ''){ //カテゴリ分け表示の場合 }else{ //カテゴリIDの取得 $data['gallery_category'] = $this->GalleryCategories->find() ->where(['GalleryCategories.company_id' => $company_data->id]) ->where(['GalleryCategories.name' => urldecode($slug)]) ->where(['GalleryCategories.display_flag' => 1]) //gallery_archiveの暫定対策 ->where(['GalleryCategories.gallery_kind IS NULL']) ->where(['GalleryCategories.delete_flag' => 0]) ->first(); if(empty($data['gallery_category'])){ return $this->redirect('/'); } //※※※暫定処理 $tag_category = urldecode($slug); //カテゴリに紐付くデータ取得 $query = $this->Galleries->find() ->contain(['GalleryCategories']) ->where(['Galleries.company_id' => $company_data->id]) ->where(['Galleries.gallery_category_id' => $data['gallery_category']->id]) ->where(['Galleries.display_flag' => 1]) ->where(['Galleries.delete_flag' => 0]) //gallery_archiveの暫定対策 ->where(['OR' => [['Galleries.gallery_kind' => ''], ['Galleries.gallery_kind IS NULL']]]) //->order(['Galleries.sort' => 'ASC']); ->order(['GalleryCategories.sort' => 'ASC', 'Galleries.sort' => 'ASC']); //->order(['release_date' => 'DESC']) //カテゴリ一覧 $data['gallery_categories'] = $this->GalleryCategories->find() ->select(['GalleryCategories.name']) ->where(['GalleryCategories.company_id' => $company_data->id]) ->where(['GalleryCategories.display_flag' => 1]) ->where(['GalleryCategories.delete_flag' => 0]) //gallery_archiveの暫定対策 ->where(['GalleryCategories.gallery_kind IS NULL']) ->order(['GalleryCategories.sort' => 'ASC']) ->all(); // //$data['tmp_layer'] = '/'.urldecode($slug).'/gallery_archive/'; $data['tmp_layer'] = '/gallery_archive/'.urldecode($slug).'/'; } // if(!empty($tmp_reference_page->keywords)){ if(!empty($tag_category)){ $data['page']->keywords = urldecode($tag_category).','.$tmp_reference_page->keywords; }else{ $data['page']->keywords = $tmp_reference_page->keywords; } } if(!empty($tmp_reference_page->description)){ if(!empty($tag_category)){ $data['page']->description = urldecode($tag_category).'。'.$tmp_reference_page->description; }else{ $data['page']->description = $tmp_reference_page->description; } } if(!empty($tmp_reference_page->title)){ if($fixed_slug == 'detail' || $fixed_slug2 == 'detail'){ $data['page']->title = urldecode($data['gallery']->name).' | '.$tmp_reference_page->title; }elseif(!empty($tag_category)){ $data['page']->title = urldecode($tag_category).' | '.$tmp_reference_page->title; }else{ $data['page']->title = $tmp_reference_page->title; } } if(!empty($tmp_reference_page->h1_text)){ if(!empty($tag_category)){ $data['page']->h1_text = urldecode($tag_category).' | '.$tmp_reference_page->h1_text; }else{ $data['page']->h1_text = $tmp_reference_page->h1_text; } } if(!empty($tmp_reference_page->name)){ $data['page']->name = $tmp_reference_page->name; } if(!empty($tmp_reference_page->common_footer_flag)){ $data['page']->common_footer_flag = $tmp_reference_page->common_footer_flag; } if(!empty($tmp_reference_page->image01)){ $data['page']->image01 = $tmp_reference_page->image01; } if(!empty($tmp_reference_page->other1)){ $data['page']->other1 = $tmp_reference_page->other1; } if(!empty($tmp_reference_page->other2)){ $data['page']->other2 = $tmp_reference_page->other2; } if(!empty($tmp_reference_page->other3)){ $data['page']->other3 = $tmp_reference_page->other3; } if(!empty($tmp_reference_page->other4)){ $data['page']->other4 = $tmp_reference_page->other4; } if(!empty($tmp_reference_page->header_headline)){ $data['page']->header_headline = $tmp_reference_page->header_headline; } if(!empty($tmp_reference_page->header_subheadline)){ $data['page']->header_subheadline = $tmp_reference_page->header_subheadline; } if(!empty($tmp_reference_page->header_text)){ $data['page']->header_text = $tmp_reference_page->header_text; } if(!empty($tmp_reference_page->header_align)){ $data['page']->header_align = $tmp_reference_page->header_align; } if(!empty($tmp_reference_page->header_align2)){ $data['page']->header_align2 = $tmp_reference_page->header_align2; } if(!empty($tmp_reference_page->footer_headline)){ $data['page']->footer_headline = $tmp_reference_page->footer_headline; } if(!empty($tmp_reference_page->footer_subheadline)){ $data['page']->footer_subheadline = $tmp_reference_page->footer_subheadline; } if(!empty($tmp_reference_page->footer_text)){ $data['page']->footer_text = $tmp_reference_page->footer_text; } if(!empty($tmp_reference_page->footer_align)){ $data['page']->footer_align = $tmp_reference_page->footer_align; } if(!empty($tmp_reference_page->footer_align2)){ $data['page']->footer_align2 = $tmp_reference_page->footer_align2; } if(!empty($tmp_reference_page->slug)){ $data['page']->tmp_slug = $tmp_reference_page->slug; } //暫定対策※※※ //if(empty($data['page']->slug) && $data['page']->pagetype_id != 8){ if(empty($data['page']->slug) && $page_mode == 'gallery_archive'){ $data['page']->slug = $tmp_reference_page->name; $data['breadcrumb'][2]['name'] = $tmp_reference_page->name; } //暫定対策※※※ //if(empty($data['breadcrumb'][2]['name']) && $data['page']->pagetype_id != 8){ if(empty($data['breadcrumb'][2]['name']) && $page_mode == 'gallery_archive'){ $data['breadcrumb'][2]['name'] = $tmp_reference_page->name; } // if(!empty($data['setting']->gallery_num)){ $limit = $data['setting']->gallery_num; }else{ $limit = 10; } if(!empty($data['page']->other2)){ $limit = $data['page']->other2; }else{ $limit = 10; } $query->limit($limit); //件数やページ数のセット if(!empty($page_num)){ $offset = ($limit * $page_num) - $limit; $query->offset($offset); } $count = $query->count(); $galleries = $query->all(); $data['galleries'] = $galleries; //ページネーション if(($count / $limit) > 0 && $count > 0){ $data['pagenation'] = $this->pagenation_data($page_num, $count, $limit); } } //comparison_archive 関連データ if($page_mode == 'comparison_archive'){ //後から追加した機能、ギャラリーの枠として使用されているページのデータ取得 $tmp_reference_page_query = $this->Pages->find() ->where(['Pages.company_id' => $company_data->id]) ->where(['Pages.pagetype_id' => 9]) ->where(['Pages.delete_flag' => 0]); //->first(); /*if(!empty($data['page']->page_kind)){ $tmp_reference_page_query->where(['Pages.page_kind' => $data['page']->page_kind]); }else{ $tmp_reference_page_query->where(['OR' => [['Pages.page_kind' => ''], ['Pages.page_kind IS NULL']]]); }*/ $tmp_reference_page = $tmp_reference_page_query->first(); //カテゴリ分け表示、一括表示の分岐 //一括表示の場合 if($slug == 'all'){ //全カテゴリカテゴリのデータ取得 $query = $this->Comparisons->find() ->where(['Comparisons.company_id' => $company_data->id]) //->where(['Comparisons.comparison_category_id IN' => $category_id_array]) ->where(['Comparisons.display_flag' => 1]) ->where(['Comparisons.delete_flag' => 0]); //->order(['Comparisons.sort' => 'ASC']); if($tmp_reference_page->sort_flag == 1){ $query->order(['Comparisons.sort' => 'DESC']); }else{ $query->order(['Comparisons.sort' => 'ASC']); } //->order(['release_date' => 'DESC']) // if(isset($data['setting']->comparison_archive_title) && !empty($data['setting']->comparison_archive_title)){ $slug == $data['setting']->comparison_archive_title; $data['comparison_category'] = new \stdClass; $data['comparison_category']->name = $data['setting']->comparison_archive_title; //$data['comparison_category']->abbr = $data['setting']->comparison_archive_title; }else{ $slug == '全てを表示'; $data['comparison_category'] = new \stdClass; $data['comparison_category']->name = '全てを表示'; //$data['comparison_category']->abbr = '全てを表示'; } //カテゴリ一覧 $data['comparison_categories'] = $this->ComparisonCategories->find() ->select(['ComparisonCategories.name', 'ComparisonCategories.abbr']) ->where(['ComparisonCategories.company_id' => $company_data->id]) ->where(['ComparisonCategories.display_flag' => 1]) ->where(['ComparisonCategories.delete_flag' => 0]) ->order(['ComparisonCategories.sort' => 'ASC']) ->all(); // //$data['tmp_layer'] = '/'.$slug.'/comparison_archive/'; $data['tmp_layer'] = '/comparison_archive/all/'; }elseif(is_numeric($slug)){ //カテゴリIDの取得 $tmp_block = $this->Blocks->find() //※※※後で絞込精査 //->select(['Pages.id', 'Pages.pagetype_id', 'Pages.parent_id', 'Pages.name', 'Pages.slug', 'Pages.title', 'Pages.sort', 'Pagetypes.id', 'Pagetypes.name']) //->contain(['BlockDetails']) ->where(['Blocks.id' => $slug]) ->where(['Blocks.company_id' => $company_data->id]) ->where(['Blocks.delete_flag' => 0]) ->first(); if(!empty($tmp_block)){ $data['comparison_category'] = new \stdClass; //$data['comparison_category']->name = $tmp_block->block_name; //$data['comparison_category']->abbr = $tmp_block->block_abbr; $data['comparison_category']->name = $tmp_block->headline; $data['comparison_category']->abbr = $tmp_block->subheadline; }else{ $data['comparison_category'] = new \stdClass; $data['comparison_category']->name = ''; $data['comparison_category']->abbr = ''; } $category_id_array = []; if($tmp_block->tmp_flag == 1){ if(!empty($tmp_block->text1)){ $category_id_array = explode(',', $tmp_block->text1); } }else{ if(!empty($tmp_block->block_details)){ $category_id_array = explode(',', $tmp_block->block_details[0]->content); } } //カテゴリに紐付くデータ取得 $query = $this->Comparisons->find() ->where(['Comparisons.company_id' => $company_data->id]) ->where(['Comparisons.comparison_category_id IN' => $category_id_array]) ->where(['Comparisons.display_flag' => 1]) ->where(['Comparisons.delete_flag' => 0]); //->order(['Comparisons.sort' => 'ASC']); if($tmp_reference_page->sort_flag == 1){ $query->order(['Comparisons.sort' => 'DESC']); }else{ $query->order(['Comparisons.sort' => 'ASC']); } //->order(['release_date' => 'DESC']) //カテゴリ一覧 //$data['comparison_categories'] = ''; // //data['tmp_layer'] = '/'.$slug.'/comparison_archive/'; //$data['tmp_layer'] = '/comparison_archive/'.$slug.'/'; $data['tmp_layer'] = '/comparison_archive/'.$tmp_block->headline.'/'; //全カテゴリ表示の場合 }elseif($slug == ''){ //カテゴリ分け表示の場合 }else{ //カテゴリIDの取得 $data['comparison_category'] = $this->ComparisonCategories->find() ->where(['ComparisonCategories.company_id' => $company_data->id]) ->where(['ComparisonCategories.name' => urldecode($slug)]) ->where(['ComparisonCategories.display_flag' => 1]) ->where(['ComparisonCategories.delete_flag' => 0]) ->first(); if(empty($data['comparison_category'])){ return $this->redirect('/'); } //カテゴリに紐付くデータ取得 $query = $this->Comparisons->find() ->where(['Comparisons.company_id' => $company_data->id]) ->where(['Comparisons.comparison_category_id' => $data['comparison_category']->id]) ->where(['Comparisons.display_flag' => 1]) ->where(['Comparisons.delete_flag' => 0]); //->order(['Comparisons.sort' => 'ASC']); if($tmp_reference_page->sort_flag == 1){ $query->order(['Comparisons.sort' => 'DESC']); }else{ $query->order(['Comparisons.sort' => 'ASC']); } //->order(['release_date' => 'DESC']) //カテゴリ一覧 $data['comparison_categories'] = $this->ComparisonCategories->find() ->select(['ComparisonCategories.name']) ->where(['ComparisonCategories.company_id' => $company_data->id]) ->where(['ComparisonCategories.display_flag' => 1]) ->where(['ComparisonCategories.delete_flag' => 0]) ->order(['ComparisonCategories.sort' => 'ASC']) ->all(); // //$data['tmp_layer'] = '/'.urldecode($slug).'/comparison_archive/'; $data['tmp_layer'] = '/comparison_archive/'.urldecode($slug).'/'; } //後から追加した機能、ビフォーアフターの枠として使用されているページのデータ取得 $data['reference_page'] = $this->Pages->find() ->where(['Pages.company_id' => $company_data->id]) ->where(['Pages.pagetype_id' => 9]) ->where(['Pages.delete_flag' => 0]) ->first(); // if(!empty($tmp_reference_page->keywords)){ $data['page']->keywords = $tmp_reference_page->keywords; } if(!empty($tmp_reference_page->description)){ $data['page']->description = $tmp_reference_page->description; } if(!empty($tmp_reference_page->title)){ $data['page']->title = $tmp_reference_page->title; } if(!empty($tmp_reference_page->h1_text)){ $data['page']->h1_text = $tmp_reference_page->h1_text; } if(!empty($tmp_reference_page->name)){ $data['page']->name = $tmp_reference_page->name; } if(!empty($tmp_reference_page->common_footer_flag)){ $data['page']->common_footer_flag = $tmp_reference_page->common_footer_flag; } if(!empty($tmp_reference_page->image01)){ $data['page']->image01 = $tmp_reference_page->image01; } if(!empty($tmp_reference_page->other1)){ $data['page']->other1 = $tmp_reference_page->other1; } if(!empty($tmp_reference_page->other2)){ $data['page']->other2 = $tmp_reference_page->other2; } if(!empty($tmp_reference_page->other3)){ $data['page']->other3 = $tmp_reference_page->other3; } if(!empty($tmp_reference_page->header_headline)){ $data['page']->header_headline = $tmp_reference_page->header_headline; } if(!empty($tmp_reference_page->header_subheadline)){ $data['page']->header_subheadline = $tmp_reference_page->header_subheadline; } if(!empty($tmp_reference_page->header_text)){ $data['page']->header_text = $tmp_reference_page->header_text; } if(!empty($tmp_reference_page->header_align)){ $data['page']->header_align = $tmp_reference_page->header_align; } if(!empty($tmp_reference_page->header_align2)){ $data['page']->header_align2 = $tmp_reference_page->header_align2; } if(!empty($tmp_reference_page->footer_headline)){ $data['page']->footer_headline = $tmp_reference_page->footer_headline; } if(!empty($tmp_reference_page->footer_subheadline)){ $data['page']->footer_subheadline = $tmp_reference_page->footer_subheadline; } if(!empty($tmp_reference_page->footer_text)){ $data['page']->footer_text = $tmp_reference_page->footer_text; } if(!empty($tmp_reference_page->footer_align)){ $data['page']->footer_align = $tmp_reference_page->footer_align; } if(!empty($tmp_reference_page->footer_align2)){ $data['page']->footer_align2 = $tmp_reference_page->footer_align2; } //暫定対策※※※ if(empty($data['page']->slug)){ $data['page']->slug = $tmp_reference_page->name; $data['breadcrumb'][2]['name'] = $tmp_reference_page->name; } //暫定対策※※※ if(empty($data['breadcrumb'][2]['name'])){ $data['breadcrumb'][2]['name'] = $tmp_reference_page->name; } // if(!empty($data['setting']->comparison_num)){ $limit = $data['setting']->comparison_num; }elseif(!empty($data['page']->other2)){ $limit = $data['page']->other2; }else{ $limit = 10; } $query->limit($limit); //件数やページ数のセット if(!empty($page_num)){ $offset = ($limit * $page_num) - $limit; $query->offset($offset); } $count = $query->count(); $comparisons = $query->all(); $data['comparisons'] = $comparisons; //ページネーション if(($count / $limit) > 0 && $count > 0){ $data['pagenation'] = $this->pagenation_data($page_num, $count, $limit); } } //recruit 関連データ if(isset($data['page']->pagetype_id) && $data['page']->pagetype_id == '10'){ //詳細ページの場合 if($fixed_slug == 'detail'){ $data['recruit'] = $this->Recruits->find() ->where(['Recruits.id' => $tag_category]) ->where(['Recruits.company_id' => $company_data->id]) ->where(['Recruits.display_flag' => 1]) ->where(['Recruits.delete_flag' => 0]) ->first(); $data['breadcrumb'][2]['name'] = '詳細'; $data['breadcrumb'][2]['url'] = ''; // $data['page']->keywords = $data['recruit']->job_type; $data['page']->description = $data['recruit']->content; $data['page']->title = $data['recruit']->title.' | '.$data['page']->title; $data['page']->h1_text = $data['recruit']->title; //一覧の場合 }else{ //紐付くデータの取得 $query = $this->Recruits->find() ->where(['Recruits.company_id' => $company_data->id]) ->where(['Recruits.display_flag' => 1]) ->where(['Recruits.delete_flag' => 0]) ->order(['Recruits.sort' => 'ASC']); // if(!empty($data['page']->other2)){ $limit = $data['page']->other2; }else{ $limit = 10; } //カテゴリの絞り込み if($fixed_slug == 'category'){ $tmp_recruit_categories_query = $this->RecruitCategories->find() ->select(['RecruitCategories.id']) ->where(['RecruitCategories.company_id' => $company_data->id]) ->where(['RecruitCategories.name' => urldecode($tag_category)]) ->where(['RecruitCategories.display_flag' => 1]) ->where(['RecruitCategories.delete_flag' => 0]); //->first(); //ギャラリー複数化 /*if(!empty($data['page']->page_kind)){ $tmp_recruit_categories_query->where(['RecruitCategories.gallery_kind' => $data['page']->page_kind]); }else{ $tmp_recruit_categories_query->where(['RecruitCategories.gallery_kind IS NULL']); }*/ $tmp_recruit_categories = $tmp_recruit_categories_query->first(); $query->where(['Recruits.recruit_category_id' => $tmp_recruit_categories->id]); } // $query->limit($limit); //件数やページ数のセット if(!empty($page_num)){ $offset = ($limit * $page_num) - $limit; $query->offset($offset); } $count = $query->count(); $recruits = $query->all(); $data['recruits'] = $recruits; //カテゴリ一覧 $data['recruit_categories'] = $this->RecruitCategories->find() ->select(['RecruitCategories.name', 'RecruitCategories.abbr']) ->where(['RecruitCategories.company_id' => $company_data->id]) ->where(['RecruitCategories.display_flag' => 1]) ->where(['RecruitCategories.delete_flag' => 0]) ->order(['RecruitCategories.sort' => 'ASC']) ->all(); //ページネーション if(($count / $limit) > 0 && $count > 0){ $data['pagenation'] = $this->pagenation_data($page_num, $count, $limit); } } } //キャッシュの確認(URL構造データ)※※※ページネーションがある時、レイヤーデータも異なるので調整 //slug_plusの追加 if(!empty($page_slug_plus)){ $data['tmp_layer'] = $page_slug_plus->slug_plus; $data['tmp_layer_pagenum'] = ''; }elseif(!empty($data['page'])){ //※※※暫定対応、detailの時はリダイレクトさせない $data['tmp_layer'] = $this->layer_data($company_data->id, $slug, $data['page']->pagetype_id, $data['page']->parent_id, $request_uri, $preview_mode, $fixed_slug, $page_num, $page_mode, $tag_category, $archive_year, $archive_month, $data['page']->slug_plus); if(isset($page_num) && $page_num > 1){ $data['tmp_layer_pagenum'] = $data['tmp_layer'].$page_num.'/'; }else{ $data['tmp_layer_pagenum'] = $data['tmp_layer']; } }else{ $data['tmp_layer'] = ''; $data['tmp_layer_pagenum'] = ''; } // if(!isset($data['tmp_layer_prev'])){ if(isset($data['pagenation']['now_page']) && !empty($data['pagenation']['now_page']) && $data['pagenation']['now_page'] > 1){ $data['tmp_layer_prev'] = $data['pagenation']['now_page'] - 1; }else{ $data['tmp_layer_prev'] = ''; } } if(!isset($data['tmp_layer_next'])){ if(isset($data['pagenation']['total_page']) && !empty($data['pagenation']['total_page']) && isset($data['pagenation']['now_page']) && !empty($data['pagenation']['now_page']) && $data['pagenation']['now_page'] < $data['pagenation']['total_page']){ $data['tmp_layer_next'] = $data['pagenation']['now_page'] + 1; }else{ $data['tmp_layer_next'] = ''; } } //問い合わせフォームのPOSTがあった場合の処理 if ($this->request->is('post')) { $contact_id = $this->request->data['contact_id']; $form_recruit_id = $this->request->data['form_recruit_id']; $form_block_id = $this->request->data['block_id']; //unset($this->request->data['contact_id']); // $contact['parent'] = $this->Contacts->find() ->where(['Contacts.id' => $contact_id]) ->where(['Contacts.company_id' => $company_data->id]) ->where(['Contacts.delete_flag' => 0]) ->first(); $contact_details = $this->ContactDetails->find() //->where(['ContactDetails.company_id' => $company_id]) ->where(['ContactDetails.contact_id' => $contact_id]) ->where(['ContactDetails.delete_flag' => 0]) ->order(['ContactDetails.sort' => 'ASC']) ->all(); //form_recruit_idがある場合、リクルート情報を取得 $form_recruit_name = ''; if(!empty($form_recruit_id)){ $form_recruit = $this->Recruits->find() ->where(['Recruits.id' => $form_recruit_id]) ->where(['Recruits.company_id' => $company_data->id]) ->where(['Recruits.delete_flag' => 0]) ->first(); if(!empty($form_recruit)){ $form_recruit_name = $form_recruit->title; } } //確認画面からのPOST if($fixed_slug == 'form_conf'){ //除外IPか確認 if(strpos($contact['parent']->rejection_ip, $_SERVER['REMOTE_ADDR']) === false){ //$this->log($contact['parent']->form_sender_server, "debug"); $file_flag = 0; $file_arrays = []; //SMTPサーバー関連の設定が済んでいる場合 if(!empty($contact['parent']->form_sender_server) && !empty($contact['parent']->form_sender_account) && !empty($contact['parent']->form_sender_password) && !empty($contact['parent']->form_sender_port)){ // require LIB.'PHPMailer/src/PHPMailer.php'; require LIB.'PHPMailer/src/SMTP.php'; require LIB.'PHPMailer/src/POP3.php'; require LIB.'PHPMailer/src/Exception.php'; require LIB.'PHPMailer/src/OAuth.php'; require LIB.'PHPMailer/language/phpmailer.lang-ja.php'; // //use PHPMailer\PHPMailer\PHPMailer; //use PHPMailer\PHPMailer\Exception; mb_language("japanese"); mb_internal_encoding("UTF-8"); // $user_mail = ''; foreach($contact_details as $contact_detail){ if($contact_detail->type == 'mail'){ $user_mail = $this->request->data[$contact_detail->id]; } } //メッセージ $msg2 = "\n\n"; foreach($contact_details as $contact_detail){ //空欄項目の取り扱い if($contact['parent']->blank_flag == 1 && isset($this->request->data[$contact_detail->id]) && empty($this->request->data[$contact_detail->id])){ }else{ if($contact_detail->type == 'checkbox'){ if(isset($this->request->data[$contact_detail->id]) && !empty($this->request->data[$contact_detail->id])){ $msg2 .= "■".$contact_detail->name."\n"; $msg2 .= "".implode('、',$this->request->data[$contact_detail->id])."\n\n"; } }elseif($contact_detail->type == 'image' && !empty($this->request->data[$contact_detail->id.'_tmp_name'])){ //$msg2 .= "■".$contact_detail->name."\n"; $tmp_file_array = []; $tmp_file_array['tmp_name'] = $this->request->data[$contact_detail->id.'_tmp_name']; $tmp_file_array['name'] = $this->request->data[$contact_detail->id.'_name']; $tmp_file_array['tmp_file_name'] = $this->request->data[$contact_detail->id.'_tmp_file_name']; $tmp_file_array['type'] = $this->request->data[$contact_detail->id.'_type']; $tmp_file_array['subdomain'] = $this->request->data[$contact_detail->id.'_subdomain']; $file_arrays[] = $tmp_file_array; $file_flag = 1; }else{ $msg2 .= "■".$contact_detail->name."\n"; $msg2 .= "".$this->request->data[$contact_detail->id]."\n\n"; } } } //$msg2 .= "\n"; //$msg2 .= $contact['parent']->user_sign; //SMTPの設定 $mailer = new PHPMailer();//インスタンス生成 $mailer->IsSMTP();//SMTPを作成 $mailer->Host = $contact['parent']->form_sender_server; $mailer->CharSet = 'utf-8'; $mailer->SMTPAuth = TRUE; $mailer->Username = $contact['parent']->form_sender_account; $mailer->Password = $contact['parent']->form_sender_password; //$mailer->SMTPSecure = 'tls'; // if($contact['parent']->form_sender_server == 'smtp.gmail.com' || $contact['parent']->form_sender_server == 'smtp.office365.com'){ $mailer->SMTPSecure = 'tls'; $mailer->Port = 587; $mailer->SMTPOptions = [ 'ssl' => [ 'verify_peer' => false ,'verify_peer_name' => false ,'allow_self_signed' => true ] ]; }else{ $mailer->Port = $contact['parent']->form_sender_port; } //$mailer->SMTPDebug = 2; //メール本体・ユーザーへメール送信 if(!empty($user_mail)){ $mailer->AddAddress($user_mail); // To宛先 $mailer->From = $contact['parent']->from_mail; //差出人の設定 //$mailer->FromName = mb_convert_encoding($contact['parent']->from_mail,"UTF-8","AUTO"); $mailer->FromName = mb_convert_encoding($contact['parent']->from_name,"UTF-8","AUTO"); $mailer->Subject = mb_convert_encoding($contact['parent']->user_subject,"UTF-8","AUTO");//件名の設定 //$message = mb_strimwidth($page->content, 0, 200, "...", "UTF-8");//メール本文 $msg1 = ''; $msg1 .= $contact['parent']->user_content; // $msg = $msg1.$msg2."\n".$contact['parent']->user_sign; $msg = str_replace("\r", "", $msg); $mailer->Body = mb_convert_encoding($msg,"UTF-8","AUTO");//メッセージ本体 //$this->log($file_flag, "debug"); //添付ファイルがある場合 $AddAttachment = []; if($file_flag == 1){ // if(SV_KIND2 == 'IPP3_1'){ $attachment_url = 'https://onerank-cms.com'; }elseif(SV_KIND2 == 'IPP3_2'){ $attachment_url = 'https://onerank-cms-2.com'; }elseif(SV_KIND2 == 'IPP3_3'){ $attachment_url = 'https://onerank-cms-3.com'; }elseif(SV_KIND2 == 'dev(AWS)'){ $attachment_url = 'https://onerank-hybrid-dev.com'; }elseif(SV_KIND2 == 'dev2(AWS)'){ $attachment_url = 'https://onerank-hybrid-dev2.com'; }elseif(SV_KIND2 == 'dev3(AWS)'){ $attachment_url = 'https://onerank-hybrid-dev3.com'; }else{ $attachment_url = 'https://onerank-cms-dev.com'; } // foreach($file_arrays as $file_array){ if($file_array['type'] == 'application/pdf'){ //ディレクトリが存在するかチェック if(!file_exists('/var/www/html/application/webroot/common/upload_data/'.$file_array['subdomain'].'/file')){ exec('sudo mkdir /var/www/html/application/webroot/common/upload_data/'.$file_array['subdomain'].'/file'); exec('sudo chmod 777 /var/www/html/application/webroot/common/upload_data/'.$file_array['subdomain'].'/file'); } $mailer->AddAttachment("/var/www/html/application/webroot/common/upload_data/".$file_array['subdomain']."/file/".$file_array['tmp_file_name'], $file_array['tmp_file_name'], 'base64', 'application/pdf'); $tmp_AddAttachment = []; $tmp_AddAttachment[0] = $file_array['type']; $tmp_AddAttachment[1] = $attachment_url."/common/upload_data/".$file_array['subdomain']."/file/".$file_array['tmp_file_name']; $tmp_AddAttachment[2] = $file_array['tmp_file_name']; //$tmp_AddAttachment[3] = 'base64'; $AddAttachment[] = $tmp_AddAttachment; }else{ $mailer->AddAttachment("/var/www/html/application/webroot/common/upload_data/".$file_array['subdomain']."/image/".$file_array['tmp_file_name']); $tmp_AddAttachment = []; $tmp_AddAttachment[0] = $file_array['type']; $tmp_AddAttachment[1] = $attachment_url."/common/upload_data/".$file_array['subdomain']."/image/".$file_array['tmp_file_name']; $tmp_AddAttachment[2] = $file_array['tmp_file_name']; $AddAttachment[] = $tmp_AddAttachment; } } } //送信処理 //if($_SERVER['REMOTE_ADDR'] == '202.12.244.62'){ //if($company_data->server_kind == 1){ /*$headers = [ 'Content-Type: application/json', 'Accept-Charset: UTF-8', ];*/ $post_data = []; $post_data['Host'] = $contact['parent']->form_sender_server; $post_data['CharSet'] = 'utf-8'; $post_data['SMTPAuth'] = true; $post_data['Username'] = $contact['parent']->form_sender_account; $post_data['Password'] = $contact['parent']->form_sender_password; $post_data['SMTPSecure'] = false; $post_data['SMTPAutoTLS'] = false; $post_data['Port'] = $contact['parent']->form_sender_port; //$mailer->AddAddress = $post_data['AddAddress']; $post_data['todata'][] = $user_mail; $post_data['to'] = $user_mail; $post_data['From'] = $contact['parent']->from_mail; //$post_data['FromName'] = mb_convert_encoding($contact['parent']->from_mail,"UTF-8","AUTO"); $post_data['FromName'] = mb_convert_encoding($contact['parent']->from_name,"UTF-8","AUTO"); $post_data['addReplyTo'] = ''; $post_data['Subject'] = mb_convert_encoding($contact['parent']->user_subject,"UTF-8","AUTO"); $post_data['Body'] = mb_convert_encoding($msg,"UTF-8","AUTO"); $post_data['AddAttachment'] = $AddAttachment; $post_data['company_id'] = $company_data->id; $post_data['REMOTE_ADDR'] = $_SERVER['REMOTE_ADDR']; $post_data_json = json_encode($post_data, JSON_UNESCAPED_UNICODE); $mailer_json = json_encode($mailer, JSON_UNESCAPED_UNICODE); $this->Mail->send($post_data); /*$ch = curl_init(); // curl_setopt($ch, CURLOPT_URL, 'https://onerank-cms-2.com/mails/ipp-new-mail-send/'); curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST"); // メソッド指定 Ver. POST curl_setopt($ch, CURLOPT_HTTPHEADER, $headers); //curl_setopt($ch, CURLOPT_POSTFIELDS, $post_data); // パラメータをセット curl_setopt($ch, CURLOPT_POSTFIELDS, $post_data_json); // パラメータをセット //curl_setopt($ch, CURLOPT_POSTFIELDS, $mailer); // パラメータをセット curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); // 証明書の検証を行わない curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); // レスポンスを文字列で受け取る // $response_json = curl_exec($ch); $response = json_decode($response_json, true); //$post_http_info = curl_getinfo($ch); curl_close($ch); }else{ if($mailer->Send()){ //$this->log('success', "debug"); }else{ //$this->log($mailer, "debug"); //$this->log('error', "debug"); //$this->log($mailer->ErrorInfo, "debug"); //echo "送信に失敗しました" . $mailer->ErrorInfo; } }*/ } //SMTPの設定 $mailer = new PHPMailer();//インスタンス生成 $mailer->IsSMTP();//SMTPを作成 $mailer->Host = $contact['parent']->form_sender_server; $mailer->CharSet = 'utf-8'; $mailer->SMTPAuth = TRUE; $mailer->Username = $contact['parent']->form_sender_account; $mailer->Password = $contact['parent']->form_sender_password; // if($contact['parent']->form_sender_server == 'smtp.gmail.com' || $contact['parent']->form_sender_server == 'smtp.office365.com'){ $mailer->SMTPSecure = 'tls'; $mailer->Port = 587; $mailer->SMTPOptions = [ 'ssl' => [ 'verify_peer' => false ,'verify_peer_name' => false ,'allow_self_signed' => true ] ]; }else{ $mailer->Port = $contact['parent']->form_sender_port; } //$mailer->SMTPDebug = 2; //メール本体・管理者へメール送信 $mailer->AddAddress($contact['parent']->reception_mail); // To宛先 $mailer->From = $contact['parent']->from_mail; //差出人の設定 //$mailer->FromName = mb_convert_encoding($contact['parent']->from_mail,"UTF-8","AUTO"); $mailer->FromName = mb_convert_encoding($contact['parent']->from_name,"UTF-8","AUTO"); $mailer->Subject = mb_convert_encoding($contact['parent']->admin_subject,"UTF-8","AUTO");//件名の設定 //$message = mb_strimwidth($page->content, 0, 200, "...", "UTF-8");//メール本文 $msg3 = ''; $msg3 .= $contact['parent']->admin_content; $msg3 .= "\n\n"; // if(!empty($form_recruit_name)){ $msg4 .= "■参照元の求人\n"; $msg4 .= " ".$form_recruit_name."\n"; $msg3 = $msg3.$msg4; } // $msg = $msg3.$msg2; $msg = $msg."\n\n(SMTP経由)"; $msg = str_replace("\r", "", $msg); $mailer->Body = mb_convert_encoding($msg,"UTF-8","AUTO");//メッセージ本体 //添付ファイルがある場合 $AddAttachment = []; if($file_flag == 1){ // if(SV_KIND2 == 'IPP3_1'){ $attachment_url = 'https://onerank-cms.com'; }elseif(SV_KIND2 == 'IPP3_2'){ $attachment_url = 'https://onerank-cms-2.com'; }elseif(SV_KIND2 == 'IPP3_3'){ $attachment_url = 'https://onerank-cms-3.com'; }elseif(SV_KIND2 == 'dev(AWS)'){ $attachment_url = 'https://onerank-hybrid-dev.com'; }elseif(SV_KIND2 == 'dev2(AWS)'){ $attachment_url = 'https://onerank-hybrid-dev2.com'; }elseif(SV_KIND2 == 'dev3(AWS)'){ $attachment_url = 'https://onerank-hybrid-dev3.com'; }else{ $attachment_url = 'https://onerank-cms-dev.com'; } // foreach($file_arrays as $file_array){ if($file_array['type'] == 'application/pdf'){ //ディレクトリが存在するかチェック if(!file_exists('/var/www/html/application/webroot/common/upload_data/'.$file_array['subdomain'].'/file')){ exec('sudo mkdir /var/www/html/application/webroot/common/upload_data/'.$file_array['subdomain'].'/file'); exec('sudo chmod 777 /var/www/html/application/webroot/common/upload_data/'.$file_array['subdomain'].'/file'); } $mailer->AddAttachment("/var/www/html/application/webroot/common/upload_data/".$file_array['subdomain']."/file/".$file_array['tmp_file_name'], $file_array['tmp_file_name'], 'base64', 'application/pdf'); $tmp_AddAttachment = []; $tmp_AddAttachment[0] = $file_array['type']; $tmp_AddAttachment[1] = $attachment_url."/common/upload_data/".$file_array['subdomain']."/file/".$file_array['tmp_file_name']; $tmp_AddAttachment[2] = $file_array['tmp_file_name']; //$tmp_AddAttachment[3] = 'base64'; $AddAttachment[] = $tmp_AddAttachment; }else{ $mailer->AddAttachment("/var/www/html/application/webroot/common/upload_data/".$file_array['subdomain']."/image/".$file_array['tmp_file_name']); $tmp_AddAttachment = []; $tmp_AddAttachment[0] = $file_array['type']; $tmp_AddAttachment[1] = $attachment_url."/common/upload_data/".$file_array['subdomain']."/image/".$file_array['tmp_file_name']; $tmp_AddAttachment[2] = $file_array['tmp_file_name']; $AddAttachment[] = $tmp_AddAttachment; } } } //送信処理 //if($_SERVER['REMOTE_ADDR'] == '202.12.244.62'){ //if($company_data->server_kind == 1){ /*$headers = [ 'Content-Type: application/json', 'Accept-Charset: UTF-8', ];*/ $post_data = []; $post_data['Host'] = $contact['parent']->form_sender_server; $post_data['CharSet'] = 'utf-8'; $post_data['SMTPAuth'] = true; $post_data['Username'] = $contact['parent']->form_sender_account; $post_data['Password'] = $contact['parent']->form_sender_password; $post_data['SMTPSecure'] = false; $post_data['SMTPAutoTLS'] = false; $post_data['Port'] = $contact['parent']->form_sender_port; //$mailer->AddAddress = $post_data['AddAddress']; //メール本体・管理者へメール送信 if(strpos($contact['parent']->reception_mail, ',') !== false){ $reception_mail_array = explode(',', $contact['parent']->reception_mail); foreach($reception_mail_array as $key=>$val){ $post_data['todata'][] = $val; } }else{ $post_data['todata'][] = $contact['parent']->reception_mail; } $post_data['to'] = $contact['parent']->reception_mail; $post_data['From'] = $contact['parent']->from_mail; //$post_data['FromName'] = mb_convert_encoding($contact['parent']->from_mail,"UTF-8","AUTO"); $post_data['FromName'] = mb_convert_encoding($contact['parent']->from_name,"UTF-8","AUTO"); if(!empty($user_mail) && $contact['parent']->reply_flag == 1){ $post_data['addReplyTo'] = $user_mail; } $post_data['Subject'] = mb_convert_encoding($contact['parent']->admin_subject,"UTF-8","AUTO"); $post_data['Body'] = mb_convert_encoding($msg,"UTF-8","AUTO"); $post_data['AddAttachment'] = $AddAttachment; $post_data['company_id'] = $company_data->id; $post_data['REMOTE_ADDR'] = $_SERVER['REMOTE_ADDR']; $post_data_json = json_encode($post_data, JSON_UNESCAPED_UNICODE); $mailer_json = json_encode($mailer, JSON_UNESCAPED_UNICODE); $this->Mail->send($post_data); /*$ch = curl_init(); // curl_setopt($ch, CURLOPT_URL, 'https://onerank-cms-2.com/mails/ipp-new-mail-send/'); curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST"); // メソッド指定 Ver. POST curl_setopt($ch, CURLOPT_HTTPHEADER, $headers); //curl_setopt($ch, CURLOPT_POSTFIELDS, $post_data); // パラメータをセット curl_setopt($ch, CURLOPT_POSTFIELDS, $post_data_json); // パラメータをセット //curl_setopt($ch, CURLOPT_POSTFIELDS, $mailer); // パラメータをセット curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); // 証明書の検証を行わない curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); // レスポンスを文字列で受け取る // $response_json = curl_exec($ch); $response = json_decode($response_json, true); //$post_http_info = curl_getinfo($ch); curl_close($ch); }else{ if($mailer->Send()){ //$this->log('success', "debug"); }else{ //$this->log($mailer, "debug"); //$this->log('error', "debug"); //$this->log($mailer->ErrorInfo, "debug"); //echo "送信に失敗しました" . $mailer->ErrorInfo; } }*/ // $this->Cookie->delete('ipp_lambda_form'); //完了画面へリダイレクト //return $this->redirect($this->request->data['back_url'].'form_send/'); //return $this->redirect($this->request->data['back_url'].'form_send/#'.$form_block_id); //return $this->redirect($this->request->data['back_url'].'form_send/'.$form_block_id.'/#'.$form_block_id); //通常のsend_mail関数による送信 }else{ $user_mail = ''; foreach($contact_details as $contact_detail){ if($contact_detail->type == 'mail'){ $user_mail = $this->request->data[$contact_detail->id]; } } //メッセージ $base_msg = "\n\n"; foreach($contact_details as $contact_detail){ //空欄項目の取り扱い if($contact['parent']->blank_flag == 1 && isset($this->request->data[$contact_detail->id]) && empty($this->request->data[$contact_detail->id])){ }else{ if($contact_detail->type == 'checkbox'){ if(isset($this->request->data[$contact_detail->id]) && !empty($this->request->data[$contact_detail->id])){ $base_msg .= "■".$contact_detail->name."\n"; $base_msg .= "".implode('、',$this->request->data[$contact_detail->id])."\n\n"; } }elseif($contact_detail->type == 'image' && !empty($this->request->data[$contact_detail->id.'_tmp_name'])){ $tmp_file_array = []; $tmp_file_array['tmp_name'] = $this->request->data[$contact_detail->id.'_tmp_name']; $tmp_file_array['name'] = $this->request->data[$contact_detail->id.'_name']; $tmp_file_array['tmp_file_name'] = $this->request->data[$contact_detail->id.'_tmp_file_name']; $tmp_file_array['type'] = $this->request->data[$contact_detail->id.'_type']; $tmp_file_array['subdomain'] = $this->request->data[$contact_detail->id.'_subdomain']; $file_arrays[] = $tmp_file_array; $file_flag = 1; }else{ $base_msg .= "■".$contact_detail->name."\n"; $base_msg .= "".$this->request->data[$contact_detail->id]."\n\n"; } } } //$base_msg .= "\n"; //$base_msg .= $contact['parent']->user_sign; //ユーザーへメール送信 if(!empty($user_mail)){ $to = $user_mail; $subject = $contact['parent']->user_subject; //$from = mb_encode_mimeheader(" (自動送信メール) ").'<'.$contact['parent']->from_mail'>'; $from = $contact['parent']->from_mail; //$header = "From: $from"; $user_content = ''; $user_content .= $contact['parent']->user_content; // $user_msg = $user_content.$base_msg."\n".$contact['parent']->user_sign; $user_msg = str_replace("\r", "", $user_msg); //mb_language("Japanese"); //mb_internal_encoding ("SJIS"); //$subject = mb_convert_encoding($subject, "SJIS", "auto"); //$user_msg = mb_convert_encoding($user_msg, "SJIS", "auto"); /*if(mb_send_mail($to, $subject, $user_msg, $header)){ $this->log('送信成功', 'debug'); } else { $this->log('送信失敗', 'debug'); echo "送信エラー\n"; }*/ mb_language("ja"); mb_internal_encoding("UTF-8"); // if($file_flag == 1){ // ヘッダー設定 $header = ''; $header .= "Content-Type: multipart/mixed;boundary=\"__BOUNDARY__\"\n"; $header .= "Return-Path: " . $from . " \n"; $header .= "From: " . $from ." \n"; $header .= "Sender: " . $from ." \n"; $header .= "Reply-To: " . $from . " \n"; $header .= "Organization: " . $from . " \n"; $header .= "X-Sender: " . $from . " \n"; $header .= "X-Priority: 3 \n"; // テキストメッセージを記述 $body = "--__BOUNDARY__\n"; $body .= "Content-Type: text/plain; charset=\"ISO-2022-JP\"\n\n"; $body .= $user_msg . "\n"; $body .= "--__BOUNDARY__\n"; // ファイルを添付 foreach($file_arrays as $file_array){ $body .= "Content-Type: application/octet-stream; name=\"{$file_array['name']}\"\n"; $body .= "Content-Disposition: attachment; filename=\"{$file_array['name']}\"\n"; $body .= "Content-Transfer-Encoding: base64\n"; $body .= "\n"; if($file_array['type'] == 'application/pdf'){ //ディレクトリが存在するかチェック if(!file_exists('/var/www/html/application/webroot/common/upload_data/'.$file_array['subdomain'].'/file')){ exec('sudo mkdir /var/www/html/application/webroot/common/upload_data/'.$file_array['subdomain'].'/file'); exec('sudo chmod 777 /var/www/html/application/webroot/common/upload_data/'.$file_array['subdomain'].'/file'); } $body .= chunk_split(base64_encode(file_get_contents("/var/www/html/application/webroot/common/upload_data/".$file_array['subdomain']."/file/".$file_array['tmp_file_name']))); }else{ $body .= chunk_split(base64_encode(file_get_contents("/var/www/html/application/webroot/common/upload_data/".$file_array['subdomain']."/image/".$file_array['tmp_file_name']))); } $body .= "--__BOUNDARY__\n"; } if(mb_send_mail($to, $subject, $body, $header)){ } else { echo "送信エラー\n"; } }else{ $header = "From: $from"; $subject_sjis = mb_convert_encoding($subject, "SJIS", "auto"); $msg_sjis = mb_convert_encoding($user_msg, "SJIS", "auto"); if(mb_send_mail($to, $subject, $user_msg, $header)){ } else { echo "送信エラー\n"; } } } //管理者へメール送信 $to = $contact['parent']->reception_mail; $subject = $contact['parent']->admin_subject; //$from = mb_encode_mimeheader(" (自動送信メール) ").'<'.$contact['parent']->from_mail'>'; $from = $contact['parent']->from_mail; // $msg3 = ''; $msg3 .= $contact['parent']->admin_content; $msg3 .= "\n\n"; // if(!empty($form_recruit_name)){ $msg4 .= "■参照元の求人\n"; $msg4 .= " ".$form_recruit_name."\n"; $msg3 = $msg3.$msg4; } // $msg = $msg3.$base_msg; $msg = str_replace("\r", "", $msg); //mb_language("Japanese"); //mb_internal_encoding ("SJIS"); //$subject = mb_convert_encoding($subject, "SJIS", "auto"); //$msg_sjis = mb_convert_encoding($msg, "SJIS", "auto"); mb_language("ja"); mb_internal_encoding("UTF-8"); // if($file_flag == 1){ // ヘッダー設定 $header = ''; $header .= "Content-Type: multipart/mixed;boundary=\"__BOUNDARY__\"\n"; $header .= "Return-Path: " . $from . " \n"; $header .= "From: " . $from ." \n"; $header .= "Sender: " . $from ." \n"; //$header .= "Reply-To: " . $from . " \n"; if(!empty($user_mail) && $contact['parent']->reply_flag == 1){ $header .= "Reply-To: " . "".mb_encode_mimeheader (mb_convert_encoding($user_mail,"ISO-2022-JP","AUTO")) ."" . "<".$user_mail."> \n"; }else{ $header .= "Reply-To: " . $from . " \n"; } $header .= "Organization: " . $from . " \n"; $header .= "X-Sender: " . $from . " \n"; $header .= "X-Priority: 3 \n"; // テキストメッセージを記述 $body = "--__BOUNDARY__\n"; $body .= "Content-Type: text/plain; charset=\"ISO-2022-JP\"\n\n"; $body .= $msg . "\n"; $body .= "--__BOUNDARY__\n"; // ファイルを添付 foreach($file_arrays as $file_array){ $body .= "Content-Type: application/octet-stream; name=\"{$file_array['name']}\"\n"; $body .= "Content-Disposition: attachment; filename=\"{$file_array['name']}\"\n"; $body .= "Content-Transfer-Encoding: base64\n"; $body .= "\n"; if($file_array['type'] == 'application/pdf'){ //ディレクトリが存在するかチェック if(!file_exists('/var/www/html/application/webroot/common/upload_data/'.$file_array['subdomain'].'/file')){ exec('sudo mkdir /var/www/html/application/webroot/common/upload_data/'.$file_array['subdomain'].'/file'); exec('sudo chmod 777 /var/www/html/application/webroot/common/upload_data/'.$file_array['subdomain'].'/file'); } $body .= chunk_split(base64_encode(file_get_contents("/var/www/html/application/webroot/common/upload_data/".$file_array['subdomain']."/file/".$file_array['tmp_file_name']))); }else{ $body .= chunk_split(base64_encode(file_get_contents("/var/www/html/application/webroot/common/upload_data/".$file_array['subdomain']."/image/".$file_array['tmp_file_name']))); } $body .= "--__BOUNDARY__\n"; } if(mb_send_mail($to, $subject, $body, $header)){ } else { echo "送信エラー\n"; } }else{ $header = "From: $from"; $subject_sjis = mb_convert_encoding($subject, "SJIS", "auto"); $msg_sjis = mb_convert_encoding($msg, "SJIS", "auto"); if(mb_send_mail($to, $subject, $msg, $header)){ } else { echo "送信エラー\n"; } } // $this->Cookie->delete('ipp_lambda_form'); //完了画面へリダイレクト //return $this->redirect($this->request->data['back_url'].'form_send/'); //return $this->redirect($this->request->data['back_url'].'form_send/#'.$form_block_id); //return $this->redirect($this->request->data['back_url'].'form_send/'.$form_block_id.'/#'.$form_block_id); } //ContactLogs $contact_log = $this->ContactLogs->newEntity(); $contact_log_save_data['company_id'] = $company_data->id; $contact_log_save_data['contact_id'] = $contact_id; $contact_log_save_data['form_recruit_id'] = $form_recruit_id; $contact_log_save_data['content'] = $msg; $contact_log_save_data['user_agent'] = $_SERVER['HTTP_USER_AGENT']; $contact_log_save_data['remote_addr'] = $_SERVER['REMOTE_ADDR']; $contact_log_save_data['delete_flag'] = 0; $contact_log = $this->ContactLogs->patchEntity($contact_log, $contact_log_save_data); $this->ContactLogs->save($contact_log); // return $this->redirect($this->request->data['back_url'].'form_send/'.$form_block_id.'/#'.$form_block_id); }else{ //ContactLogs /*$contact_log = $this->ContactLogs->newEntity(); $contact_log_save_data['company_id'] = $company_data->id; $contact_log_save_data['contact_id'] = $contact_id; $contact_log_save_data['form_recruit_id'] = $form_recruit_id; $contact_log_save_data['content'] = $msg; $contact_log_save_data['user_agent'] = '[SPAM] '.$_SERVER['HTTP_USER_AGENT']; $contact_log_save_data['remote_addr'] = $_SERVER['REMOTE_ADDR']; $contact_log_save_data['delete_flag'] = 0; $contact_log = $this->ContactLogs->patchEntity($contact_log, $contact_log_save_data); $this->ContactLogs->save($contact_log);*/ // return $this->redirect($this->request->data['back_url'].'form_send/'.$form_block_id.'/#'.$form_block_id); } //フォームTOPからのPOST }else{ // if(!empty($contact['parent']->grv3_sitekey) && !empty($contact['parent']->grv3_secretkey)){ $recaptchaToken = $this->request->data['recaptchaToken']; $params = array( 'secret' => $contact['parent']->grv3_secretkey, 'response' => $recaptchaToken, ); $url = 'https://www.google.com/recaptcha/api/siteverify?'; $url .= http_build_query($params); $ch = curl_init(); curl_setopt( $ch, CURLOPT_URL, $url ); curl_setopt( $ch, CURLOPT_HEADER, false ); curl_setopt( $ch, CURLOPT_RETURNTRANSFER, true ); curl_setopt( $ch, CURLOPT_TIMEOUT, 120 ); $response = curl_exec( $ch ); curl_close( $ch ); $verify = json_decode($response); if($verify->success) { //var_dump('true'); } else { //var_dump('false'); return $this->redirect('/', '301'); } } // $data['form_error_message'] = []; $file_count = 1; foreach($contact_details as $contact_detail){ //必須チェック if($contact_detail->required == 1 && empty($this->request->data[$contact_detail->id])){ if($contact_detail->type == 'text' || $contact_detail->type == 'textarea' || $contact_detail->type == 'mail' || $contact_detail->type == 'zip' || $contact_detail->type == 'address'){ $data['form_error_message'][$contact_detail->id] = $contact_detail->name.'が未入力です'; }else{ $data['form_error_message'][$contact_detail->id] = $contact_detail->name.'が未選択です'; } } //必須チェック(チェックボックス用) if($contact_detail->required == 1 && $contact_detail->type == 'checkbox'){ $checkbox_flag = 0; foreach($this->request->data[$contact_detail->id] as $key=>$val){ if(!empty($val)){ $checkbox_flag = 1; } } if($checkbox_flag == 0){ $data['form_error_message'][$contact_detail->id] = $contact_detail->name.'が未選択です'; } } //メールアドレスの形式チェック if($contact_detail->type == 'mail' && !empty($this->request->data[$contact_detail->id])){ if(!preg_match("/^([a-zA-Z0-9])+([a-zA-Z0-9\?\*\[|\]%'=~^\{\}\/\+!#&\$\._-])*@([a-zA-Z0-9_-])+\.([a-zA-Z0-9\._-]+)+$/", $this->request->data[$contact_detail->id])){ $data['form_error_message'][$contact_detail->id] = 'メールアドレスの形式が正しくありません'; } } // if($contact_detail->type == 'image'){ //ファイル必須チェック if($contact_detail->required == 1 && empty($this->request->data[$contact_detail->id]['tmp_name'])){ $data['form_error_message'][$contact_detail->id] = $contact_detail->name.'が未選択です'; }elseif(!empty($this->request->data[$contact_detail->id]['tmp_name'])){ if($this->request->data[$contact_detail->id]['type'] == 'application/pdf'){ //ディレクトリが存在するかチェック if(!file_exists('/var/www/html/application/webroot/common/upload_data/'.$company_data->subdomain.'/file')){ exec('sudo mkdir /var/www/html/application/webroot/common/upload_data/'.$company_data->subdomain.'/file'); exec('sudo chmod 777 /var/www/html/application/webroot/common/upload_data/'.$company_data->subdomain.'/file'); } //PDFの一時保存 $tmp_file_name = sha1($company_data->subdomain.date('YmdHis').$file_count).'.pdf'; $dirname_filename = '/var/www/html/application/webroot/common/upload_data/'.$company_data->subdomain.'/file/'.$tmp_file_name; move_uploaded_file($this->request->data[$contact_detail->id]['tmp_name'], $dirname_filename); // $this->request->data[$contact_detail->id]['tmp_file_name'] = $tmp_file_name; }else{ //画像の一時保存 $tmp_file_name = sha1($company_data->subdomain.date('YmdHis').$file_count); $imginfo = getimagesize($this->request->data[$contact_detail->id]['tmp_name']); if($imginfo[2] == 1){ $tmp_file_name = $tmp_file_name.'.gif'; }elseif($imginfo[2] == 2){ $tmp_file_name = $tmp_file_name.'.jpg'; }elseif($imginfo[2] == 3){ $tmp_file_name = $tmp_file_name.'.png'; }else{ $tmp_file_name = $row['name']; } $this->Img->upload('/var/www/html/application/webroot/common/upload_data/'.$company_data->subdomain.'/image', $this->request->data[$contact_detail->id]['tmp_name'], $tmp_file_name, 'original', 1024,$company_data->subdomain); //$this->request->data[$contact_detail->id]['binary'] = file_get_contents($this->request->data[$contact_detail->id]['tmp_name']); $this->request->data[$contact_detail->id]['tmp_file_name'] = $tmp_file_name; } } } $file_count++; } //エラーがある場合 if(!empty($data['form_error_message'])){ $data['form_input_data'] = $this->request->data; //エラーが無い場合、Cookieにセットして確認画面へ }else{ $ipp_lambda_form['back_url'] =$data['tmp_layer']; $ipp_lambda_form['form_data'] = $this->request->data; //※※※Cookie名に企業IDとか含めておいた方が良いかも $this->Cookie->write('ipp_lambda_form', $ipp_lambda_form); // //return $this->redirect($data['tmp_layer'].'form_conf/#'.$form_block_id); return $this->redirect($data['tmp_layer'].'form_conf/'.$form_block_id.'/'); } } } //問い合わせの確認画面の場合 if($fixed_slug == 'form_conf'){ $tmp_form_data = $this->Cookie->read('ipp_lambda_form'); $data['form_input_data'] = $tmp_form_data['form_data']; $data['back_url'] = $tmp_form_data['back_url']; } //問い合わせの送信完了画面の場合 if($fixed_slug == 'form_send'){ } //キャッシュの確認(セッティングデータ) //$data['setting'] = $this->setting_data($company_data->id); //キャッシュの確認(ナビゲーションメニュー) if(!empty($navigation_page_id)){ $data['navi'] = $this->sub_navi_data($company_data->id, $navigation_page_id); }else{ //if($company_data->cms_version == 1){ if($company_data->cms_version >= 1){ $data['navi'] = $this->new_navi_data($company_data->id, 'tmp'); }else{ $data['navi'] = $this->navi_data($company_data->id); } } // $data['company'] = $company_data; $data['page_num'] = $page_num; $data['fixed_slug'] = $fixed_slug; $data['tag_category'] = $tag_category; //$data['article_category'] = $article_category; //$data['article_tag'] = $article_tag; $data['tag_category'] = urldecode($tag_category); $data['page_tag'] = $page_tag; $data['archive_year'] = $archive_year; $data['archive_month'] = $archive_month; //h1 if(isset($data['page']->h1_text) && empty($data['page']->h1_text)){ $data['page']->h1_text = $data['page']->title; } //※※※暫定処理 if($preview_mode){ // if(isset($data['page']) && !empty($data['page']) && $data['page']->parent_id == null && $data['page']->parent_id != '0'){ $this->viewBuilder()->layout('template/type00'.$data['setting']->theme_id.'/index'); }elseif(isset($data['page']) && !empty($data['page']) && $page_mode == 'dictionary'){ $this->viewBuilder()->layout('template/type00'.$data['setting']->theme_id.'/dictionary'); }elseif($page_mode == 'gallery_archive' || $page_mode == 'comparison_archive'){ $this->viewBuilder()->layout('template/type00'.$data['setting']->theme_id.'/archive'); }elseif($slug == 'dictionary'){ $this->viewBuilder()->layout('template/type00'.$data['setting']->theme_id.'/d_archive'); }elseif(isset($data['page']) && !empty($data['page']) && ($data['page']->pagetype_id == 2 || $data['page']->pagetype_id == 3 || $data['page']->pagetype_id == 5 || $data['page']->pagetype_id == 12 || $fixed_slug == 'archive' || $fixed_slug == 'category' || $fixed_slug == 'tag')){ $this->viewBuilder()->layout('template/type00'.$data['setting']->theme_id.'/archive'); }elseif(isset($data['page']) && !empty($data['page']) && $fixed_slug == 'detail' || $fixed_slug2 == 'detail'){ $this->viewBuilder()->layout('template/type00'.$data['setting']->theme_id.'/detail'); }elseif(!empty($data['page'])){ $this->viewBuilder()->layout('template/type00'.$data['setting']->theme_id.'/single'); }elseif(!isset($data['setting']->theme_id) or (isset($data['setting']->theme_id) && empty($data['setting']->theme_id))){ $this->viewBuilder()->layout('template/type000/404'); }else{ if($company_data->cms_version >= 1){ if($data['setting']->webp_flag == 2){ //$this->viewBuilder()->layout('newframe_webp/404'); $this->viewBuilder()->layout('newframe/404'); }else{ $this->viewBuilder()->layout('newframe/404'); } $this->response->statusCode(404); }else{ $this->viewBuilder()->layout('template/type00'.$data['setting']->theme_id.'/404'); $this->response->statusCode(404); } } }else{ // if(isset($data['page']) && !empty($data['page']) && $data['page']->parent_id == null && $data['page']->parent_id != '0'){ $this->viewBuilder()->layout('frame/index'); }elseif(isset($data['page']) && !empty($data['page']) && $page_mode == 'dictionary'){ $this->viewBuilder()->layout('frame/dictionary'); }elseif(isset($data['page']->pagetype_id) && $data['page']->pagetype_id == '10' && $fixed_slug == 'detail'){ $this->viewBuilder()->layout('frame/recruit_detail'); }elseif(isset($data['page']->pagetype_id) && $data['page']->pagetype_id == '10'){ $this->viewBuilder()->layout('frame/recruit_archive'); }elseif(isset($data['page']->pagetype_id) && $data['page']->pagetype_id == '8' && $fixed_slug == 'detail'){ $this->viewBuilder()->layout('frame/gallery_detail'); }elseif($page_mode == 'gallery_archive'){ $this->viewBuilder()->layout('frame/gallery_archive'); }elseif(isset($data['page']->pagetype_id) && $data['page']->pagetype_id == '8'){ $this->viewBuilder()->layout('frame/new_gallery_archive'); }elseif($page_mode == 'comparison_archive'){ $this->viewBuilder()->layout('frame/comparison_archive'); }elseif($page_mode == 'tag'){ $this->viewBuilder()->layout('frame/category_tag'); }elseif($slug == 'dictionary'){ $this->viewBuilder()->layout('frame/d_archive'); }elseif(isset($data['page']->pagetype_id) && isset($data['page']) && !empty($data['page']) && ($data['page']->pagetype_id == 2 || $data['page']->pagetype_id == 3 || $data['page']->pagetype_id == 5 || $data['page']->pagetype_id == 12 || $fixed_slug == 'archive' || $fixed_slug == 'category' || $fixed_slug == 'tag')){ $this->viewBuilder()->layout('frame/archive'); }elseif(isset($data['page']) && !empty($data['page']) && $fixed_slug == 'detail' || $fixed_slug2 == 'detail'){ $this->viewBuilder()->layout('frame/detail'); }elseif(!empty($data['page'])){ $this->viewBuilder()->layout('frame/single'); }elseif(!isset($data['setting']->theme_id) or (isset($data['setting']->theme_id) && empty($data['setting']->theme_id))){ if($company_data->cms_version >= 1){ //$this->viewBuilder()->layout('newframe/404'); //$this->response->statusCode(404); $this->viewBuilder()->layout('frame/404'); $this->response->statusCode(404); }else{ $this->viewBuilder()->layout('frame/404'); $this->response->statusCode(404); } }else{ if($company_data->cms_version >= 1){ $this->viewBuilder()->layout('newframe/404'); $this->response->statusCode(404); /*$this->viewBuilder()->layout('frame/404'); $this->response->statusCode(404);*/ }else{ $this->viewBuilder()->layout('frame/404'); $this->response->statusCode(404); } } } //Basic認証の設定 /*if(OP_MODE == 'subdomain'){ $this->basic_authenticate('iplambda', 'iplambda'); }elseif(!empty($data['page']) && !empty($data['page']->basic_account) && !empty($data['page']->basic_password)){ $this->basic_authenticate($data['page']->basic_account, $data['page']->basic_password); }elseif(!empty($data['setting']->basic_account) && !empty($data['setting']->basic_password)){ $this->basic_authenticate($data['setting']->basic_account, $data['setting']->basic_password); }*/ if(!empty($data['page']) && !empty($data['page']->basic_account) && !empty($data['page']->basic_password)){ $this->basic_authenticate($data['page']->basic_account, $data['page']->basic_password); }elseif(!empty($data['setting']->basic_account) && !empty($data['setting']->basic_password)){ $this->basic_authenticate($data['setting']->basic_account, $data['setting']->basic_password); } // $data['page_mode'] = $page_mode; $data['iframe_mode'] = $iframe_mode; $data['preview_mode'] = $preview_mode; //データセット $this->set('data', $data); // //$this->set('$lock_mode', ''); } } public function page_data($company_id, $slug, $fixed_slug, $form_block_id, $tag_category, $preview_mode, $page_mode, $breadcrumb_text, $setting, $request_uri){ if(($data = Cache::read($company_id.'_'.$slug.'_page', 'page')) === false){ /*if($_SERVER['REMOTE_ADDR'] == '110.74.59.1'){ var_dump($company_id); var_dump($slug); var_dump($fixed_slug); var_dump($form_block_id); var_dump($tag_category); var_dump($preview_mode); var_dump($page_mode); var_dump($breadcrumb_text); var_dump($setting); exit; }*/ //サイトマップや辞書の場合は除外 if($slug == 'sitemap' || $slug == 'dictionary' || $page_mode == 'dictionary' || $slug == 'page'){ if($slug == 'sitemap'){ $data['page'] = new \stdClass; $data['page']->id = 9999999999; $data['page']->parent_id = '0'; $data['page']->pagetype_id = ''; $data['page']->keywords = $setting->sitemap_keywords; $data['page']->description = $setting->sitemap_description; $data['page']->title = $setting->sitemap_title; $data['page']->h1_text = $setting->sitemap_h1; $data['page']->name = 'サイトマップ'; $data['page']->slug = 'sitemap'; $data['page']->basic_account = ''; $data['page']->basic_password = ''; $data['page']->h_d_flag = 1; $data['page']->h_d_logo_flag = 1; $data['page']->h_d_navi_flag = 1; $data['page']->h_d_mv_flag = 1; $data['page']->f_d_flag = 1; $data['page']->f_d_logo_flag = 1; $data['page']->f_d_navi_flag = 1; $data['page']->f_d_sns_flag = 1; $data['breadcrumb'][1]['url'] = '/'; $data['breadcrumb'][1]['name'] = $breadcrumb_text; $data['breadcrumb'][2]['url'] = '/sitemap/'; $data['breadcrumb'][2]['name'] = 'サイトマップ'; // $data['sitemap'] = $this->sitemap_data($company_id); }elseif($slug == 'dictionary'){ $data['page'] = new \stdClass; $data['page']->id = ''; $data['page']->parent_id = '0'; $data['page']->pagetype_id = ''; $data['page']->name = ''; $data['page']->keywords = '用語一覧'; $data['page']->description = '用語一覧'; $data['page']->title = '用語一覧'; $data['page']->h1_text = '用語一覧'; $data['page']->name = '用語一覧'; $data['page']->slug = 'dictionary'; $data['page']->basic_account = ''; $data['page']->basic_password = ''; $data['page']->h_d_flag = 1; $data['page']->h_d_logo_flag = 1; $data['page']->h_d_navi_flag = 1; $data['page']->h_d_mv_flag = 1; $data['page']->f_d_flag = 1; $data['page']->f_d_logo_flag = 1; $data['page']->f_d_navi_flag = 1; $data['page']->f_d_sns_flag = 1; $data['breadcrumb'][1]['url'] = '/'; $data['breadcrumb'][1]['name'] = $breadcrumb_text; $data['breadcrumb'][2]['url'] = '/dictionary/archive/'; $data['breadcrumb'][2]['name'] = '用語一覧'; }elseif($slug == 'page'){ $data['page'] = new \stdClass; $data['page']->id = ''; $data['page']->parent_id = '0'; $data['page']->pagetype_id = ''; $data['page']->name = ''; $data['page']->keywords = 'タグ『'.urldecode($tag_category).'』のページ一覧'; $data['page']->description = 'タグ『'.urldecode($tag_category).'』のページ一覧'; $data['page']->title = 'タグ『'.urldecode($tag_category).'』のページ一覧'; $data['page']->h1_text = 'タグ『'.urldecode($tag_category).'』のページ一覧'; $data['page']->name = 'タグ『'.urldecode($tag_category).'』のページ一覧'; $data['page']->slug = 'page'; $data['page']->basic_account = ''; $data['page']->basic_password = ''; $data['page']->h_d_flag = 1; $data['page']->h_d_logo_flag = 1; $data['page']->h_d_navi_flag = 1; $data['page']->h_d_mv_flag = 1; $data['page']->f_d_flag = 1; $data['page']->f_d_logo_flag = 1; $data['page']->f_d_navi_flag = 1; $data['page']->f_d_sns_flag = 1; $data['breadcrumb'][1]['url'] = '/'; $data['breadcrumb'][1]['name'] = $breadcrumb_text; $data['breadcrumb'][2]['url'] = '/page/tag/'.urldecode($tag_category).'/'; $data['breadcrumb'][2]['name'] = urldecode($tag_category); }elseif($page_mode == 'dictionary'){ //辞書データの取得 $data['dictionary'] = $this->Dictionaries->find() ->where(['Dictionaries.name' => urldecode($slug)]) ->where(['Dictionaries.company_id' => $company_id]) ->where(['Dictionaries.display_flag' => 1]) ->where(['Dictionaries.delete_flag' => 0]) ->first(); //用語が存在するかどうか if(!empty($data['dictionary'])){ $content_org = $data['dictionary']->content; //置換用の辞書データ取得 $tmp_dictionaries = $this->Dictionaries->find() ->where(['Dictionaries.id !=' => $data['dictionary']->id]) ->where(['Dictionaries.company_id' => $company_id]) ->where(['Dictionaries.display_flag' => 1]) ->where(['Dictionaries.delete_flag' => 0]) ->all(); $dictionary_datas = []; if($tmp_dictionaries){ foreach($tmp_dictionaries as $dictionary){ $dictionary_datas[$dictionary->name] = ''.$dictionary->name.''; } uksort($dictionary_datas, function($a, $b){return mb_strlen($b, 'utf-8') - mb_strlen($a, 'utf-8');}); $data['dictionary']->content = $this->strtr_utf8($data['dictionary']->content, $dictionary_datas); } $data['page'] = new \stdClass; $data['page']->id = ''; $data['page']->parent_id = '0'; $data['page']->pagetype_id = ''; $data['page']->name = ''; $data['page']->keywords = urldecode($slug); $data['page']->description = mb_strimwidth($content_org, 0, 120, "…", "UTF-8" );; $data['page']->title = ''.urldecode($slug).' とは'; $data['page']->h1_text = urldecode($slug); $data['page']->slug = urldecode($slug); $data['page']->basic_account = ''; $data['page']->basic_password = ''; $data['page']->h_d_flag = 1; $data['page']->h_d_logo_flag = 1; $data['page']->h_d_navi_flag = 1; $data['page']->h_d_mv_flag = 1; $data['page']->f_d_flag = 1; $data['page']->f_d_logo_flag = 1; $data['page']->f_d_navi_flag = 1; $data['page']->f_d_sns_flag = 1; $data['breadcrumb'][1]['url'] = '/'; $data['breadcrumb'][1]['name'] = $breadcrumb_text; $data['breadcrumb'][2]['url'] = '/dictionary/archive/'; $data['breadcrumb'][2]['name'] = '用語一覧'; $data['breadcrumb'][3]['url'] = '/dictionary/detail/'.urldecode($slug).'/'; $data['breadcrumb'][3]['name'] = urldecode($slug); //用語にスペースを含む場合の対策 $tmp_dic_slug = str_replace(array(" ", " ", " ", "+"), "", $slug); //用語を含むページの取得 $data['hierarchies'] = $this->Pages->find() ->select(['Pages.id', 'Pages.pagetype_id', 'Pages.parent_id', 'Pages.name', 'Pages.slug', 'Pages.image01', 'Pages.description']) ->contain(['Pagetypes']) ->where(['Pages.company_id' => $company_id]) ->where(['Pages.pagetype_id !=' => 7]) //->where(['Pages.content LIKE' => '%'.urldecode($slug).'%']) ->where(['Pages.content LIKE' => '%'.urldecode($tmp_dic_slug).'%']) ->where(['Pages.display_flag' => 1]) ->where(['Pages.delete_flag' => 0]) ->limit(10); }else{ $data['page'] = ''; } } //gallery_archive or comparison_archive }elseif($page_mode == 'gallery_archive' || $page_mode == 'comparison_archive'){ $data['page'] = new \stdClass; $data['page']->parent_id = '0'; $data['page']->pagetype_id = ''; // $tmp_title = ''; if($page_mode == 'gallery_archive' && !empty($setting->gallery_archive_title)){ $tmp_title = $setting->gallery_archive_title; } if($page_mode == 'comparison_archive' && !empty($setting->comparison_archive_title)){ $tmp_title = $setting->comparison_archive_title; } if(is_numeric($slug)){ $tmp_block = $this->Blocks->find() //※※※後で絞込精査 //->select(['Pages.id', 'Pages.pagetype_id', 'Pages.parent_id', 'Pages.name', 'Pages.slug', 'Pages.title', 'Pages.sort', 'Pagetypes.id', 'Pagetypes.name']) //->contain(['BlockDetails']) ->where(['Blocks.id' => $slug]) ->where(['Blocks.company_id' => $company_id]) ->where(['Blocks.delete_flag' => 0]) ->first(); /* $data['page']->keywords = $tmp_block->block_name; $data['page']->description = $tmp_block->block_name; $data['page']->title = $tmp_block->block_name; $data['page']->h1_text = $tmp_block->block_name; $data['page']->name = $tmp_block->block_name; $data['page']->slug = $tmp_block->block_name; */ $data['page']->keywords = $tmp_title; $data['page']->description = $tmp_title; $data['page']->title = $tmp_title; $data['page']->h1_text = $tmp_title; $data['page']->name = $tmp_title; $data['page']->slug = $tmp_title; $data['breadcrumb'][2]['name'] = $tmp_title; }elseif($slug == '' || $slug == 'all'){ $data['page']->keywords = $tmp_title; $data['page']->description = $tmp_title; $data['page']->title = $tmp_title; $data['page']->h1_text = $tmp_title; $data['page']->name = $tmp_title; $data['page']->slug = $tmp_title; $data['breadcrumb'][2]['name'] = $tmp_title; }else{ $data['page']->keywords = urldecode($slug); $data['page']->description = urldecode($slug); $data['page']->title = urldecode($slug); $data['page']->h1_text = urldecode($slug); $data['page']->name = urldecode($slug); $data['page']->slug = urldecode($slug); $data['breadcrumb'][3]['name'] = urldecode($slug); } $data['page']->basic_account = ''; $data['page']->basic_password = ''; // $data['page']->common_footer_flag = ''; $data['page']->image01 = ''; $data['page']->other1 = ''; $data['page']->other2 = ''; $data['page']->other3 = ''; $data['page']->header_headline = ''; $data['page']->header_subheadline = ''; $data['page']->header_text = ''; $data['page']->header_align = ''; $data['page']->footer_headline = ''; $data['page']->footer_subheadline = ''; $data['page']->footer_text = ''; $data['page']->footer_align = ''; $data['page']->h_d_flag = 1; $data['page']->h_d_logo_flag = 1; $data['page']->h_d_navi_flag = 1; $data['page']->h_d_mv_flag = 1; $data['page']->f_d_flag = 1; $data['page']->f_d_logo_flag = 1; $data['page']->f_d_navi_flag = 1; $data['page']->f_d_sns_flag = 1; //暫定対応 if($page_mode == 'gallery_archive'){ $data['page'] = $this->Pages->find() ->where(['Pages.company_id' => $company_id]) ->where(['Pages.pagetype_id' => 8]) ->first(10); } // $data['breadcrumb'][1]['url'] = '/'; $data['breadcrumb'][1]['name'] = $breadcrumb_text; // if($page_mode == 'gallery_archive' && $slug == 'all'){ $data['breadcrumb'][2]['url'] = '/gallery_archive/all/'; }elseif($page_mode == 'gallery_archive' && $fixed_slug == 'detail'){ $data['breadcrumb'][2]['name'] = $data['page']->name; $data['breadcrumb'][2]['url'] = '/gallery_archive/all/'; }elseif($page_mode == 'gallery_archive' && $slug != ''){ //$data['breadcrumb'][2]['url'] = '/'.urldecode($slug).'/gallery_archive/'; $data['breadcrumb'][2]['name'] = $tmp_title; $data['breadcrumb'][2]['url'] = '/gallery_archive/all/'; $data['breadcrumb'][3]['url'] = '/gallery_archive/'.urldecode($slug).'/'; } // if($page_mode == 'comparison_archive' && $slug == 'all'){ $data['breadcrumb'][2]['url'] = '/comparison_archive/all/'; }elseif($page_mode == 'comparison_archive' && $slug != ''){ //$data['breadcrumb'][2]['url'] = '/'.urldecode($slug).'/comparison_archive/'; $data['breadcrumb'][2]['name'] = $tmp_title; $data['breadcrumb'][2]['url'] = '/comparison_archive/all/'; $data['breadcrumb'][3]['url'] = '/comparison_archive/'.urldecode($slug).'/'; } ksort($data['breadcrumb']); }else{ //※※※暫定処理 if(strpos($request_uri,'category') !== false && $fixed_slug == 'category'){ $tmp_slug_plus_array = explode('category', $request_uri); } //ページ情報取得 $query = $this->Pages->find() //->select(['Pages.id', 'Pages.pagetype_id', 'Pages.parent_id', 'Pages.name', 'Pages.slug', 'Pages.title', 'Pages.sort', 'Pagetypes.id', 'Pagetypes.name']) //->contain(['Pagetypes', 'Tags']) ->contain(['Pagetypes', 'Tags', 'BlogCategories']) //->where(['Pages.company_id' => $company_id]) //->where(['Pages.slug' => $slug]) //->where(['Frames.display_flag' => 1]) ->where(['Pages.delete_flag' => 0]); //TOPの対策 if($slug == '' or is_null($slug)){ $query->where(['Pages.company_id' => $company_id, 'OR' => [['Pages.slug' => ''], ['Pages.slug IS' => null]]]); }elseif($fixed_slug == 'category' && $tmp_slug_plus_array[0] != ''.$slug.''){ $query->where(['Pages.company_id' => $company_id]); $query->where(['Pages.slug_plus' => $tmp_slug_plus_array[0]]); }else{ $query->where(['Pages.company_id' => $company_id]); $query->where(['Pages.slug' => $slug]); } //プレビューモードではない場合 if(!$preview_mode){ $query->where(['Pages.display_flag' => 1]); } $data['page'] = $query->first(); // if(!empty($data['page'])){ //共通フッターの処理 /*if(!empty($footer_block_order)){ if(!empty($data['page']->block_order)){ $data['page']->block_order = $data['page']->block_order.','.$footer_block_order; }else{ $data['page']->block_order = $footer_block_order; } }*/ //ブロックデータの処理 if(!empty($data['page']->block_order)){ $tmp_data = $this->block_data($company_id, $data['page']->block_order, $fixed_slug, $form_block_id, 'main'); $data['blocks'] = $tmp_data['blocks']; $data['block_other'] = $tmp_data['block_other']; if(isset($tmp_data['form_input_data'])){ $data['form_input_data'] = $tmp_data['form_input_data']; }else{ $data['form_input_data'] = ''; } }else{ $data['blocks'] = ''; $data['block_other'] = ''; $data['form_input_data'] = ''; } //階層ページ情報取得 /*$data['hierarchies'] = $this->Pages->find() ->select(['Pages.id', 'Pages.pagetype_id', 'Pages.parent_id', 'Pages.name', 'Pages.slug', 'Pages.title', 'Pages.sort', 'Pages.description', 'Pages.image01', 'Pagetypes.id', 'Pagetypes.name']) ->contain(['Pagetypes']) ->where(['Pages.company_id' => $company_id]) ->where(['Pages.parent_id' => $data['page']->id]) ->where(['OR' => [['Pages.pagetype_id' => 2], ['Pages.pagetype_id' => 3], ['Pages.pagetype_id' => 4], ['Pages.pagetype_id' => 5]]]) ->where(['Pages.delete_flag' => 0]) ->all();*/ //※※※pageが記事(pagetypeが6)の場合、関連記事の取得をどうするか //上下階層の前ページを取得する様に仕様変更 //最上位のpage_idを$tmp_parent_idにセット $tmp_hierarchy_id = $data['page']->id; $tmp_parent_id = $data['page']->parent_id; while($tmp_parent_id != 0){ $tmp_child_page = $this->Pages->find() ->where(['Pages.company_id' => $company_id]) ->where(['Pages.id' => $tmp_parent_id]) ->first(); $tmp_hierarchy_id = $tmp_child_page->id; $tmp_parent_id = $tmp_child_page->parent_id; } // $data['hierarchies'] = []; $relations_not_id_array = []; $relations_not_id_array[] = $data['page']->id; //TOPを第一階層とした場合、第二回層のデータ1件を取得 if($data['page']->id != $tmp_hierarchy_id){ $tmp_hierarchy = $this->Pages->find() ->select(['Pages.id', 'Pages.pagetype_id', 'Pages.parent_id', 'Pages.name', 'Pages.slug', 'Pages.title', 'Pages.sort', 'Pages.description', 'Pages.image01', 'Pagetypes.id', 'Pagetypes.name']) ->contain(['Pagetypes']) ->where(['Pages.company_id' => $company_id]) ->where(['Pages.id' => $tmp_hierarchy_id]) ->where(['OR' => [['Pages.pagetype_id' => 2], ['Pages.pagetype_id' => 3], ['Pages.pagetype_id' => 4], ['Pages.pagetype_id' => 5]]]) ->where(['Pages.display_flag' => 1]) ->where(['Pages.delete_flag' => 0]) ->first(); if(!empty($tmp_hierarchy)){ $data['hierarchies'][] = $tmp_hierarchy; $relations_not_id_array[] = $tmp_hierarchy->id; } } //TOPを第一階層とした場合、第二回層のデータ1件に紐付く第三階層のデータを複数取得 $tmp_hierarchies1 = $this->Pages->find() ->select(['Pages.id', 'Pages.pagetype_id', 'Pages.parent_id', 'Pages.name', 'Pages.slug', 'Pages.title', 'Pages.sort', 'Pages.description', 'Pages.image01', 'Pagetypes.id', 'Pagetypes.name']) ->contain(['Pagetypes']) ->where(['Pages.id !=' => $data['page']->id]) ->where(['Pages.company_id' => $company_id]) ->where(['Pages.parent_id' => $tmp_hierarchy_id]) ->where(['OR' => [['Pages.pagetype_id' => 2], ['Pages.pagetype_id' => 3], ['Pages.pagetype_id' => 4], ['Pages.pagetype_id' => 5]]]) ->where(['Pages.display_flag' => 1]) ->where(['Pages.delete_flag' => 0]) ->all(); if(!$tmp_hierarchies1->isEmpty()){ foreach($tmp_hierarchies1 as $tmp_hierarchy1){ // $data['hierarchies'][] = $tmp_hierarchy1; $relations_not_id_array[] = $tmp_hierarchy1->id; //TOPを第一階層とした場合、第三回層のデータ1件に紐付く第四階層のデータを複数取得 $tmp_hierarchies2 = $this->Pages->find() ->select(['Pages.id', 'Pages.pagetype_id', 'Pages.parent_id', 'Pages.name', 'Pages.slug', 'Pages.title', 'Pages.sort', 'Pages.description', 'Pages.image01', 'Pagetypes.id', 'Pagetypes.name']) ->contain(['Pagetypes']) ->where(['Pages.id !=' => $data['page']->id]) ->where(['Pages.company_id' => $company_id]) ->where(['Pages.parent_id' => $tmp_hierarchy1->id]) ->where(['OR' => [['Pages.pagetype_id' => 2], ['Pages.pagetype_id' => 3], ['Pages.pagetype_id' => 4], ['Pages.pagetype_id' => 5]]]) ->where(['Pages.display_flag' => 1]) ->where(['Pages.delete_flag' => 0]) ->all(); if(!$tmp_hierarchies2->isEmpty()){ foreach($tmp_hierarchies2 as $tmp_hierarchy2){ $data['hierarchies'][] = $tmp_hierarchy2; $relations_not_id_array[] = $tmp_hierarchy2->id; } } } } //関連度の高いページを取得※※※aaa $data['relations'] = []; $relation_data = []; //フレーム一覧を取得 $query = $this->Pages->find('all') //->select(['Pages.id', 'Pages.name', 'Pages.slug', 'Pagetypes.name', 'Pagetypes.abbr', 'Tags.name']) ->select(['Pages.id', 'Pages.parent_id', 'Pages.name', 'Pages.slug', 'Pages.content', 'Pages.image01', 'Pages.description']) ->contain(['Tags']) ->where(['Pages.company_id' => $company_id]) //TOPと固定ページのみ対象 ->where(['Pages.pagetype_id IN' => [1, 4]]) ->where(['Pages.display_flag' => 1]) ->where(['Pages.delete_flag' => 0]) ->where([ 'NOT' => ['Pages.id IN' => $relations_not_id_array] ]) ->order(['Pages.sort' => 'ASC']); //->toArray(); $relation_data['pages'] = $query->toArray(); // //$return_data = []; if(!empty($relation_data['pages'])){ //TOP $count = 1; /*foreach($relation_data['pages'] as $row){ if(is_null($row->parent_id)){ $save_data['name'] = $row->name; $save_data['image01'] = $row->image01; $save_data['layer_num'] = 1; $save_data['slug_plus'] = '/'; //該当ページの文字数 $total_count = mb_strlen($row->content, 'UTF-8'); if($total_count != 0){ // $match_rate = 0; foreach($data['page']->tags as $tmp_tag){ //キーワードの出現回数 $occurrences = mb_substr_count($row->content, $tmp_tag->name); //キーワードのトータル文字数 $keyword_count = mb_strlen($tmp_tag->name, 'UTF-8') * $occurrences; //キーワード占有率 $match_rate = $match_rate + ($keyword_count / $total_count * 100); } $save_data['match_rate'] = round($match_rate, 2); }else{ $save_data['match_rate'] = 0; } $data['relations'][] = $save_data; $count++; } }*/ foreach($relation_data['pages'] as $row1){ if($row1->parent_id == 0 && !is_null($row1->parent_id)){ $save_data['id'] = $row1->id; $save_data['name'] = $row1->name; $save_data['image01'] = $row1->image01; $save_data['layer_num'] = 2; $save_data['slug_plus'] = '/'.$row1->slug.'/'; $save_data['description'] = $row1->description; //該当ページの文字数 $total_count = mb_strlen($row1->content, 'UTF-8'); if($total_count != 0){ // $match_rate = 0; foreach($data['page']->tags as $tmp_tag){ //キーワードの出現回数 $occurrences = mb_substr_count($row1->content, $tmp_tag->name); //キーワードのトータル文字数 $keyword_count = mb_strlen($tmp_tag->name, 'UTF-8') * $occurrences; //キーワード占有率 $match_rate = $match_rate + ($keyword_count / $total_count * 100); } if(round($match_rate, 2) == 0){ $save_data['match_rate'] = 0; }else{ $save_data['match_rate'] = round($match_rate, 2).$count; $data['relations'][]= $save_data; $count++; } }else{ $save_data['match_rate'] = 0; } //$data['relations'][]= $save_data; //$count++; foreach($relation_data['pages'] as $row2){ if($row2->parent_id == $row1->id){ $save_data['id'] = $row2->id; $save_data['name'] = $row2->name; $save_data['image01'] = $row2->image01; $save_data['layer_num'] = 3; $save_data['slug_plus'] = '/'.$row1->slug.'/'.$row2->slug.'/'; $save_data['description'] = $row2->description; //該当ページの文字数 $total_count = mb_strlen($row2->content, 'UTF-8'); if($total_count != 0){ // $match_rate = 0; foreach($data['page']->tags as $tmp_tag){ //キーワードの出現回数 $occurrences = mb_substr_count($row2->content, $tmp_tag->name); //キーワードのトータル文字数 $keyword_count = mb_strlen($tmp_tag->name, 'UTF-8') * $occurrences; //キーワード占有率 $match_rate = $match_rate + ($keyword_count / $total_count * 100); } if(round($match_rate, 2) == 0){ $save_data['match_rate'] = 0; }else{ $save_data['match_rate'] = round($match_rate, 2).$count; $data['relations'][] = $save_data; $count++; } }else{ $save_data['match_rate'] = 0; } //$data['relations'][] = $save_data; //$count++; foreach($relation_data['pages'] as $row3){ if($row3->parent_id == $row2->id){ $save_data['id'] = $row3->id; $save_data['parent_id'] = $row2->id; $save_data['name'] = $row3->name; $save_data['image01'] = $row3->image01; $save_data['layer_num'] = 4; $save_data['slug_plus'] = '/'.$row1->slug.'/'.$row2->slug.'/'.$row3->slug.'/'; $save_data['description'] = $row3->description; //該当ページの文字数 $total_count = mb_strlen($row3->content, 'UTF-8'); if($total_count != 0){ // $match_rate = 0; foreach($data['page']->tags as $tmp_tag){ //キーワードの出現回数 $occurrences = mb_substr_count($row3->content, $tmp_tag->name); //キーワードのトータル文字数 $keyword_count = mb_strlen($tmp_tag->name, 'UTF-8') * $occurrences; //キーワード占有率 $match_rate = $match_rate + ($keyword_count / $total_count * 100); } if(round($match_rate, 2) == 0){ $save_data['match_rate'] = 0; }else{ $save_data['match_rate'] = round($match_rate, 2).$count; $data['relations'][] = $save_data; $count++; } }else{ $save_data['match_rate'] = 0; } //$data['relations'][] = $save_data; //$count++; } } } } } } } //sort用のID配列 $match_rate = []; foreach($data['relations'] as $key=>$val){ $match_rate[$key] = $val['match_rate']; } array_multisort($match_rate, SORT_DESC, $data['relations']); //$this->log($data['relations'], 'debug'); //※※※aaa }else{ //404エラーを記録 $access_log = $this->AccessLogs->newEntity(); $save_data['company_id'] = $company_id; $save_data['request_url'] = (isset($_SERVER['REQUEST_URI'])) ? $_SERVER['REQUEST_URI'] : ''; $save_data['status_code'] = '404'; $save_data['user_agent'] = (isset($_SERVER['HTTP_USER_AGENT'])) ? $_SERVER['HTTP_USER_AGENT'] : ''; $save_data['http_referer'] = (isset($_SERVER['HTTP_REFERER'])) ? $_SERVER['HTTP_REFERER'] : ''; $save_data['remote_addr'] = (isset($_SERVER['REMOTE_ADDR'])) ? $_SERVER['REMOTE_ADDR'] : ''; $access_log = $this->AccessLogs->patchEntity($access_log, $save_data); $this->AccessLogs->save($access_log); } //パンくずリスト $data['breadcrumb'] = []; // if(!empty($data['page'])){ // if(!empty($tag_category) && $fixed_slug == 'category'){ $data['breadcrumb'][5]['url'] = '/'.$data['page']->slug.'/category/'.$tag_category.'/'; $data['breadcrumb'][5]['name'] = urldecode($tag_category); } // if($data['page']->parent_id != null or $data['page']->parent_id == '0'){ if($data['page']->pagetype_id == 6){ $bc4_slug = 'detail/'.$data['page']->slug; }else{ $bc4_slug = $data['page']->slug; } //$data['breadcrumb'][4]['url'] = '/'.$data['page']->slug.'/'; $data['breadcrumb'][4]['url'] = '/'.$bc4_slug.'/'; $data['breadcrumb'][4]['name'] = $data['page']->name; $data['breadcrumb'][4]['id'] = $data['page']->id; if($data['page']->parent_id != '0'){ $bc3 = $this->Pages->get($data['page']->parent_id); $data['breadcrumb'][3]['url'] = '/'.$bc3->slug.'/'; $data['breadcrumb'][3]['name'] = $bc3->name; $data['breadcrumb'][3]['id'] = $bc3->id; $data['breadcrumb'][4]['url'] = '/'.$bc3->slug.$data['breadcrumb'][4]['url']; if($bc3->parent_id != '0'){ $bc2 = $this->Pages->get($bc3->parent_id); $data['breadcrumb'][2]['url'] = '/'.$bc2->slug.'/'; $data['breadcrumb'][2]['name'] = $bc2->name; $data['breadcrumb'][2]['id'] = $bc2->id; $data['breadcrumb'][3]['url'] = '/'.$bc2->slug.$data['breadcrumb'][3]['url']; $data['breadcrumb'][4]['url'] = '/'.$bc2->slug.$data['breadcrumb'][4]['url']; } } }else{ $data['breadcrumb'][2]['url'] = '/'; $data['breadcrumb'][2]['name'] = '指定されたページはございません'; } $data['breadcrumb'][1]['url'] = '/'; $data['breadcrumb'][1]['name'] = $breadcrumb_text; } // // $data['breadcrumb'] = array_reverse($data['breadcrumb']); //キャッシュの書き込み ※※※ //Cache::write($company_id.'_'.$slug.'_page', $data, 'page'); } } return $data; } public function layer_string($company_id, $slug){ //slugからページデータの取得 $tmp_page = $this->Pages->find() ->select(['Pages.id', 'Pages.parent_id', 'Pages.pagetype_id']) //->contain(['Pagetypes']) ->where(['Pages.slug' => $slug]) ->where(['Pages.company_id' => $company_id]) ->where(['Pages.delete_flag' => 0]) ->first(); } public function layer_data($company_id, $slug, $pagetype_id, $parent_id, $request_uri, $preview_mode, $fixed_slug, $page_num, $page_mode, $tag_category, $archive_year, $archive_month, $slug_plus){ $layer = ''; //if(($parent_id != 0 && $parent_id != NULL) || ($parent_id == 0)){ //ブログ・新着情報の一覧系 if(($fixed_slug == 'category' || $fixed_slug == 'tag') && ($pagetype_id != 8 && $pagetype_id != 10)){ //$layer = $request_uri; if(isset($slug_plus) && !empty($slug_plus)){ $layer = $slug_plus.$fixed_slug.'/'.$tag_category.'/'; }else{ $layer = '/'.$slug.'/'.$fixed_slug.'/'.$tag_category.'/'; } // }elseif($slug == 'dictionary' && $fixed_slug == 'archive'){ $layer = '/dictionary/archive/'; // }elseif(!empty($archive_year) && !empty($archive_month) && $fixed_slug == 'archive'){ if(!empty($page_num)){ //$layer = rtrim($request_uri, $page_num); $cut = strlen($page_num) + 1; $layer = substr($request_uri, 0, strlen($request_uri)-$cut); }else{ $layer = $request_uri; } // }elseif($page_mode == 'dictionary' && $fixed_slug == 'detail'){ $layer = '/dictionary/detail/'.$slug.'/'; // }elseif($parent_id != NULL){ //if(($layer = Cache::read($company_id.'_'.$slug.'_layer', 'page')) === false){ //URL構造が正しいか確認 $layer = '/'.$slug.'/'; $while_count = 0; while($parent_id != 0){ //ページ情報取得 $tmp_page = $this->Pages->find() ->select(['Pages.id', 'Pages.parent_id', 'Pages.slug']) ->contain(['Pagetypes']) ->where(['Pages.id' => $parent_id]) ->where(['Pages.company_id' => $company_id]) //->where(['Frames.display_flag' => 1]) ->where(['Pages.delete_flag' => 0]) ->first(); if(!empty($tmp_page)){ $parent_id = $tmp_page->parent_id; if($fixed_slug == 'detail'){ if($while_count == 0){ $layer = '/'.$tmp_page->slug.'/'.$fixed_slug.$layer; }else{ $layer = '/'.$tmp_page->slug.'/'.$layer; } }else{ if($pagetype_id == 6){ $layer = '/'.$tmp_page->slug.'/detail/'.$layer; }else{ $layer = '/'.$tmp_page->slug.$layer; } } }else{ } $while_count++; } if($fixed_slug == 'comparison_archive' || $fixed_slug == 'gallery_archive'){ $layer = '/'.$fixed_slug.'/'.$slug.'/'; } /*if(!empty($fixed_slug) && !empty($tag_category)){ $layer = $layer.'/'.$fixed_slug.'/'.$tag_category.'/'; }*/ //※※※form_confとform_sendも含めないと、リダイレクトしてしまう if($layer != $request_uri && ($fixed_slug != 'detail' && $slug != 'page' && $fixed_slug != 'form_conf' && $fixed_slug != 'form_send') && empty($page_num)){ return $this->redirect($layer, '301'); } //キャッシュの書き込み ※※※ //Cache::write($company_id.'_'.$slug.'_layer', $layer, 'page'); //} //if($layer != $request_uri && ($fixed_slug != 'detail' && $fixed_slug != 'form_conf' && $fixed_slug != 'form_send')){ /*if($layer != $request_uri && ($fixed_slug != 'detail')){ return $this->redirect($layer, '301'); }*/ //TOPページの場合 }elseif($pagetype_id == 1){ $layer = '/'; }else{ if($fixed_slug == 'detail' && $pagetype_id == 8){ $layer = '/'.$slug.'/'.$fixed_slug.'/'.$tag_category.'/'; }elseif($fixed_slug == 'detail' || $fixed_slug == 'comparison_archive' || $fixed_slug == 'gallery_archive'){ $layer = '/'.$fixed_slug.'/'.$slug.'/'; }else{ $layer = '/'.$slug.'/'; } } // /*if(!empty($page_num) && $page_num != 1){//$data['pagenation']['next'] $layer = $layer.$page_num.'/'; }*/ /*if($_SERVER['REMOTE_ADDR'] == '219.113.215.10'){ var_dump('Areus事務所固定IPアドレスのみ表示している一時的なデバッグです'); var_dump($layer); var_dump($company_id); var_dump($slug); var_dump($parent_id); var_dump($request_uri); var_dump($preview_mode); var_dump($fixed_slug); var_dump($page_num); var_dump($page_mode); var_dump($tag_category); }*/ $layer = str_replace('//', '/', $layer); // return $layer; } public function pagenation_data($page_num, $count, $limit){ $pagenation = []; if(empty($page_num)){ $page_num = 1; } $pagenation['total_page'] = ceil($count / $limit); $pagenation['now_page'] = $page_num; //before if($page_num > 1){ $pagenation['now_page_before'] = $page_num - 1; }else{ $pagenation['now_page_before'] = ''; } if($page_num >= 3 && ($page_num < 5 || $pagenation['total_page'] - $page_num < 3)){ $pagenation['now_page_before2'] = $page_num - 2; }else{ $pagenation['now_page_before2'] = ''; } if($page_num >= 4 && ($page_num < 5 || $pagenation['total_page'] - $page_num < 2)){ $pagenation['now_page_before3'] = $page_num - 3; }else{ $pagenation['now_page_before3'] = ''; } if($page_num >= 5 && ($page_num < 5 || $pagenation['total_page'] - $page_num < 1)){ $pagenation['now_page_before4'] = $page_num - 4; }else{ $pagenation['now_page_before4'] = ''; } //after if($page_num < $pagenation['total_page']){ $pagenation['now_page_after'] = $page_num + 1; }else{ $pagenation['now_page_after'] = ''; } if(($pagenation['total_page'] - $page_num) >= 2 && ($page_num < 4) || $pagenation['total_page'] - $page_num == 2 || $pagenation['total_page'] - $page_num == 3){ $pagenation['now_page_after2'] = $page_num + 2; }else{ $pagenation['now_page_after2'] = ''; } if(($pagenation['total_page'] - $page_num) >= 3 && ($page_num < 3)){ $pagenation['now_page_after3'] = $page_num + 3; }else{ $pagenation['now_page_after3'] = ''; } if(($pagenation['total_page'] - $page_num) >= 4 && ($page_num < 2)){ $pagenation['now_page_after4'] = $page_num + 4; }else{ $pagenation['now_page_after4'] = ''; } // //if($page_num > 4){ if($page_num > 4 && $pagenation['total_page'] > 5){ $pagenation['prev'] = $page_num - 1; $pagenation['start'] = 1; }else{ $pagenation['prev'] = ''; $pagenation['start'] = ''; } //if($page_num < ($pagenation['total_page'] - 3)){ if($page_num < ($pagenation['total_page'] - 3) && $pagenation['total_page'] - $page_num > 3 && $pagenation['total_page'] > 5){ $pagenation['next'] = $page_num + 1; }else{ $pagenation['next'] = ''; } //if($page_num <= ($pagenation['total_page'] - 3) && $pagenation['total_page'] > 4){ if($page_num <= ($pagenation['total_page'] - 3) && $pagenation['total_page'] > 5){ $pagenation['end'] = $pagenation['total_page']; }else{ $pagenation['end'] = ''; } return $pagenation; } public function old_pagenation_data($page_num, $count, $limit){ $pagenation = []; if(empty($page_num)){ $page_num = 1; } $pagenation['total_page'] = ceil($count / $limit); $pagenation['now_page'] = $page_num; if($page_num > 1){ $pagenation['now_page_before'] = $page_num - 1; }else{ $pagenation['now_page_before'] = ''; } if($page_num < $pagenation['total_page']){ $pagenation['now_page_after'] = $page_num + 1; }else{ $pagenation['now_page_after'] = ''; } if($page_num == 3){ $pagenation['now_page_before2'] = 1; }else{ $pagenation['now_page_before2'] = ''; } if($page_num == $pagenation['total_page']){ $pagenation['now_page_after3'] = $page_num -3; }else{ $pagenation['now_page_after3'] = ''; } if($page_num > 3){ $pagenation['prev'] = $page_num - 1; $pagenation['start'] = 1; }else{ $pagenation['prev'] = ''; $pagenation['start'] = ''; } if($page_num < ($pagenation['total_page'] - 2)){ $pagenation['next'] = $page_num + 1; }else{ $pagenation['next'] = ''; } if($page_num <= ($pagenation['total_page'] - 2)){ $pagenation['end'] = $pagenation['total_page']; }else{ $pagenation['end'] = ''; } return $pagenation; } public function dictionary_data($company_id, $slug, $blocks_before, $dictionary_mode, $dictionary_tooltip, $iframe_mode){ if(($data['dictionaries'] = Cache::read($company_id.'_dictionaries', 'page')) === false){ //セッティングデータ $data['dictionaries'] = $this->Dictionaries->find() ->select(['Dictionaries.id', 'Dictionaries.name', 'Dictionaries.content']) ->where(['Dictionaries.company_id' => $company_id]) ->where(['Dictionaries.display_flag' => 1]) ->where(['Dictionaries.delete_flag' => 0]) ->all(); //キャッシュの書き込み ※※※ //Cache::write($company_id.'_dictionaries', $data['dictionaries'], 'page'); } $dictionary_datas = []; //辞書データがある場合 if($data['dictionaries']){ //辞書マッチング用の配列生成 foreach($data['dictionaries'] as $dictionary){ if($dictionary_tooltip == 1){ /*if($iframe_mode){ $dictionary_datas[$dictionary->name] = ''.$dictionary->name.''; }else{ $dictionary_datas[$dictionary->name] = ''.$dictionary->name.''; }*/ if($iframe_mode){ $dictionary_datas[$dictionary->name] = 'content), 0, 120, "…", "UTF-8" ).'" data-html="true" style="text-decoration: underline;">'.$dictionary->name.''; }else{ $dictionary_datas[$dictionary->name] = 'content), 0, 120, "…", "UTF-8" ).'" data-html="true" style="text-decoration: underline;">'.$dictionary->name.''; } }else{ if($iframe_mode){ $dictionary_datas[$dictionary->name] = ''.$dictionary->name.''; }else{ $dictionary_datas[$dictionary->name] = ''.$dictionary->name.''; } } } uksort($dictionary_datas, function($a, $b){return mb_strlen($b, 'utf-8') - mb_strlen($a, 'utf-8');}); //ブロックデータに辞書データを埋め込み if(($blocks = Cache::read($company_id.'_'.$slug.'_dictionary', 'page')) === false){ // foreach($blocks_before as $block){ //テキスト、複合コンテンツ(画像+テキスト)、複合コンテンツ(テキスト+画像) //if($tmp_pageblocks->block_type == 'block_text'){ //if($block->blocktype == 'block_text' or $block->blocktype == 'block_image_text' or $block->blocktype == 'block_text_image'){ //if($block->blocktype == 'block_text' || $block->blocktype == 'block_image_text' || $block->blocktype == 'block_text_image' || $block->blocktype == 'rich_block_image_text' || $block->blocktype == 'rich_block_text_image'){ if($block->blocktype == 'block_text' || $block->blocktype == 'block_image_text' || $block->blocktype == 'block_text_image' || $block->blocktype == 'block_image_text_re' || $block->blocktype == 'rich_block_image_text' || $block->blocktype == 'rich_block_text_image' || $block->blocktype == 'rich_block_image_text_re'){ //新構造 if($block->tmp_flag == 1){ $dictionary_i = 1; //foreach($block->block_details as $key=>$val){ $tmp_dictionary_datas = []; //if($val->type == 'text'){ //用語へのリンク:冒頭1個のみ if($dictionary_mode == 1){ $tmp_content = $block->text; //既にアンカーが付いている部分を置き換え preg_match_all('/(.*?)<\/a>/', $tmp_content, $anker_matchs); $dictionary_j = 1; $anker_matchdatas = []; if(isset($anker_matchs[0]) && !empty($anker_matchs[0])){ foreach($anker_matchs[0] as $anker_matchkey=>$anker_matchvalue){ $anker_matchdatas['tmp_dictionary2_'.sprintf("%03d", $dictionary_j)] = $anker_matchvalue; $tmp_content = str_replace($anker_matchvalue, 'tmp_dictionary2_'.sprintf("%03d", $dictionary_j), $tmp_content); $dictionary_j++; } } //マッチするデータを一時的にピックアップ foreach($dictionary_datas as $key2=>$val2){ if(strpos($tmp_content, $key2) !== false){ //$tmp_content = preg_replace("/".$key2."/", $val2, $tmp_content, 1); //unset($dictionary_datas[$key2]); $tmp_content = preg_replace("/".$key2."/", 'tmp_dictionary_'.sprintf("%03d", $dictionary_i), $tmp_content, 1); $tmp_dictionary_datas['tmp_dictionary_'.sprintf("%03d", $dictionary_i)] = $val2; unset($dictionary_datas[$key2]); } $dictionary_i++; } // foreach($tmp_dictionary_datas as $key3=>$val3){ $tmp_content = preg_replace("/".$key3."/", $val3, $tmp_content, 1); } //既にアンカーが付いている部分を元に戻す if(!empty($anker_matchdatas)){ foreach($anker_matchdatas as $matchkey=>$matchvalue){ $tmp_content = str_replace($matchkey, $matchvalue, $tmp_content); } } // $block->text_org = $block->text; $block->text = $tmp_content; //用語へのリンク:全て }else{ $tmp_content = ''; $tmp_content = $this->strtr_utf8($block->text, $dictionary_datas); $block->text_org = $block->text; $block->text = $tmp_content; } //} //} //旧構造 }else{ $dictionary_i = 1; foreach($block->block_details as $key=>$val){ $tmp_dictionary_datas = []; if($val->type == 'text'){ if($dictionary_mode == 1){ $tmp_content = $val->content; //マッチするデータを一時的にピックアップ foreach($dictionary_datas as $key2=>$val2){ if(strpos($tmp_content, $key2) !== false){ //$tmp_content = preg_replace("/".$key2."/", $val2, $tmp_content, 1); //unset($dictionary_datas[$key2]); $tmp_content = preg_replace("/".$key2."/", 'tmp_dictionary_'.sprintf("%03d", $dictionary_i), $tmp_content, 1); $tmp_dictionary_datas['tmp_dictionary_'.sprintf("%03d", $dictionary_i)] = $val2; unset($dictionary_datas[$key2]); } $dictionary_i++; } // foreach($tmp_dictionary_datas as $key3=>$val3){ $tmp_content = preg_replace("/".$key3."/", $val3, $tmp_content, 1); } $block->block_details[$key]->content_org = $val->content; $block->block_details[$key]->content = $tmp_content; }else{ $tmp_content = ''; $tmp_content = $this->strtr_utf8($val->content, $dictionary_datas); $block->block_details[$key]->content_org = $val->content; $block->block_details[$key]->content = $tmp_content; } } } } } $blocks[] = $block; //$data['pageblocks'][] = $tmp_pageblocks; } //キャッシュの書き込み ※※※ //Cache::write($company_id.'_'.$slug.'_dictionary', $blocks, 'page'); } } return $blocks; } public function new_dictionary_data($company_id, $slug, $html, $dictionary_mode, $dictionary_tooltip){ if(($data['dictionaries'] = Cache::read($company_id.'_dictionaries', 'page')) === false){ // $data['dictionaries'] = $this->Dictionaries->find() ->select(['Dictionaries.id', 'Dictionaries.name', 'Dictionaries.content']) ->where(['Dictionaries.company_id' => $company_id]) ->where(['Dictionaries.display_flag' => 1]) ->where(['Dictionaries.delete_flag' => 0]) ->all(); //キャッシュの書き込み ※※※ //Cache::write($company_id.'_dictionaries', $data['dictionaries'], 'page'); } $dictionary_datas = []; //辞書データがある場合 if($data['dictionaries']){ //辞書マッチング用の配列生成 foreach($data['dictionaries'] as $dictionary){ if($dictionary_tooltip == 1){ $dictionary_datas[$dictionary->name] = 'content), 0, 120, "…", "UTF-8" ).'" data-html="true" style="text-decoration: underline; display: inline;">'.$dictionary->name.''; }else{ $dictionary_datas[$dictionary->name] = ''.$dictionary->name.''; } } uksort($dictionary_datas, function($a, $b){return mb_strlen($b, 'utf-8') - mb_strlen($a, 'utf-8');}); //ブロックデータに辞書データを埋め込み if(($blocks = Cache::read($company_id.'_'.$slug.'_dictionary', 'page')) === false){ // $dictionary_i = 1; $tmp_dictionary_datas = []; //if($val->type == 'text'){ //用語へのリンク:冒頭1個のみ if($dictionary_mode == 1){ $tmp_content = $html; //既にアンカーが付いている部分を置き換え preg_match_all('/(.*?)<\/a>/', $tmp_content, $anker_matchs); $dictionary_j = 1; $anker_matchdatas = []; if(isset($anker_matchs[0]) && !empty($anker_matchs[0])){ foreach($anker_matchs[0] as $anker_matchkey=>$anker_matchvalue){ $anker_matchdatas['tmp_dictionary2_'.sprintf("%03d", $dictionary_j)] = $anker_matchvalue; $tmp_content = str_replace($anker_matchvalue, 'tmp_dictionary2_'.sprintf("%03d", $dictionary_j), $tmp_content); $dictionary_j++; } } //マッチするデータを一時的にピックアップ foreach($dictionary_datas as $key2=>$val2){ if(strpos($tmp_content, $key2) !== false){ //$tmp_content = preg_replace("/".$key2."/", $val2, $tmp_content, 1); //unset($dictionary_datas[$key2]); $tmp_content = preg_replace("/".$key2."/", 'tmp_dictionary_'.sprintf("%03d", $dictionary_i), $tmp_content, 1); $tmp_dictionary_datas['tmp_dictionary_'.sprintf("%03d", $dictionary_i)] = $val2; unset($dictionary_datas[$key2]); } $dictionary_i++; } // foreach($tmp_dictionary_datas as $key3=>$val3){ $tmp_content = preg_replace("/".$key3."/", $val3, $tmp_content, 1); } //既にアンカーが付いている部分を元に戻す if(!empty($anker_matchdatas)){ foreach($anker_matchdatas as $matchkey=>$matchvalue){ $tmp_content = str_replace($matchkey, $matchvalue, $tmp_content); } } // $html = $tmp_content; //用語へのリンク:全て }else{ $tmp_content = ''; $tmp_content = $this->strtr_utf8($html, $dictionary_datas); $html = $tmp_content; } //キャッシュの書き込み ※※※ //Cache::write($company_id.'_'.$slug.'_dictionary', $blocks, 'page'); } } //見出しタグ内のAタグを除去 //$html = '

これは新種です。

これは新種です。

2これは新種です2。

2これは新種です2。

'; //$pattern = '//i'; /*$pattern = '//u'; preg_match_all($pattern, $html, $heading_tag_array); if(isset($heading_tag_array[0]) && !empty($heading_tag_array[0])){ foreach($heading_tag_array[0] as $heading_tag){ $tmp_heading_tag = ''; $patterns = '/<\/*a.*?>/'; $tmp_heading_tag = preg_replace($patterns, '', $heading_tag); $html = str_replace($heading_tag, $tmp_heading_tag, $html); } }*/ // $pattern = '//i'; preg_match_all($pattern, $html, $image_tag_array); if(isset($image_tag_array[0]) && !empty($image_tag_array[0])){ foreach($image_tag_array[0] as $image_tag){ $tmp_image_tag = ''; $patterns = '/<\/*a.*?>/'; $tmp_image_tag = preg_replace($patterns, '', $image_tag); $html = str_replace($image_tag, $tmp_image_tag, $html); } } //anchor /*$pattern = '/(.*?)<\/a>/s';*/ /*$pattern = '/(?!.*\/a).*$(.*?)<\/a>.*?<\/a>/s';*/ /*$pattern = '/.*?(.*?)<\/a>.*?<\/a>/s'; preg_match_all($pattern, $html, $anchor_tag_array); if(isset($anchor_tag_array[0]) && !empty($anchor_tag_array[0])){ foreach($anchor_tag_array[0] as $anchor_tag){ $tmp_anchor_tag = ''; $patterns = '/(.*?)<\/a>/'; $tmp_anchor_tag = preg_replace($patterns, "$1", $anchor_tag); $html = str_replace($anchor_tag, $tmp_anchor_tag, $html); } }*/ /*if($_SERVER['REMOTE_ADDR'] == '221.171.97.42'){ var_dump($anchor_tag_array[0]); }*/ // return $html; } public function setting_data($company_id){ //if(($data['setting'] = Cache::read($company_id, 'setting')) === false){ //セッティングデータ $data['setting'] = $this->Settings->find() //->select(['Settings.id', 'Settings.tracking_code', 'Settings.theme_id', 'Settings.site_title', 'Settings.logo_image', 'sitemap_flag', 'sitemap_image']) ->where(['Settings.company_id' => $company_id]) ->where(['Settings.delete_flag' => 0]) ->first(); /*$data['newsetting'] = $this->Newsettings->find() //->select(['Settings.id', 'Settings.tracking_code', 'Settings.theme_id', 'Settings.site_title', 'Settings.logo_image', 'sitemap_flag', 'sitemap_image']) ->where(['Newsettings.company_id' => $company_id]) ->where(['Newsettings.delete_flag' => 0]) ->first();*/ //キャッシュの書き込み ※※※ //Cache::write($company_id, $data['setting'], 'setting'); //} //return $data['setting']; return $data; } public function navi_data($company_id){ if(($data['navi'] = Cache::read($company_id.'_navi', 'page')) === false){ //上部ナビゲーションメニュー $tmp_navi = $this->Pages->find() ->select(['Pages.parent_id', 'Pages.id', 'Pages.name', 'Pages.slug', 'Pages.pagetype_id', 'Pages.other1', 'Pages.other_flag']) ->where(['Pages.company_id' => $company_id]) //->where(['Pages.pagetype_id IN' => [1,4]]) //->where(['Pages.pagetype_id IN' => [1,2,3,4,8]]) ->where(['Pages.pagetype_id IN' => [1,2,3,4,5,8,10,11,12]]) ->where(['Pages.navi_flag' => 1]) ->where(['Pages.display_flag' => 1]) ->where(['Pages.delete_flag' => 0]) ->order(['Pages.sort' => 'ASC']) ->toArray(); if(!empty($tmp_navi)){ foreach($tmp_navi as $row){ $navi_first = []; if($row->parent_id == '0' or $row->parent_id == NULL){ $navi_first['id'] = $row->id; $navi_first['name'] = $row->name; if($row->parent_id == NULL && $row->parent_id != '0'){ $navi_first['slug'] = ''; }else{ if($row->pagetype_id == 11){ $navi_first['slug'] = $row->slug; $navi_first['other1'] = $row->other1; $navi_first['other_flag'] = $row->other_flag; }else{ $navi_first['slug'] = $row->slug.'/'; } } foreach($tmp_navi as $row2){ $navi_second = []; if($row2->parent_id == $row->id){ $navi_second['id'] = $row2->id; $navi_second['name'] = $row2->name; if($row2->pagetype_id == 11){ $navi_second['slug'] = $row2->slug; $navi_second['other1'] = $row2->other1; $navi_second['other_flag'] = $row2->other_flag; }else{ $navi_second['slug'] = $row2->slug.'/'; } foreach($tmp_navi as $row3){ $navi_third = []; if($row3->parent_id == $row2->id){ $navi_third['id'] = $row3->id; $navi_third['name'] = $row3->name; if($row3->pagetype_id == 11){ $navi_third['slug'] = $row3->slug; $navi_third['other1'] = $row3->other1; $navi_third['other_flag'] = $row3->other_flag; }else{ $navi_third['slug'] = $row3->slug.'/'; } $navi_second['third'][] = $navi_third; } } $navi_first['second'][] = $navi_second; } } $data['navi']['up'][] = $navi_first; } } } //サイドナビゲーションメニュー $tmp_navi2 = $this->Pages->find() ->select(['Pages.parent_id', 'Pages.id', 'Pages.name', 'Pages.slug', 'Pages.pagetype_id', 'Pages.other1', 'Pages.other_flag']) ->where(['Pages.company_id' => $company_id]) //->where(['Pages.pagetype_id IN' => [1,4]]) //->where(['Pages.pagetype_id IN' => [1,2,3,4,8]]) ->where(['Pages.pagetype_id IN' => [1,2,3,4,5,8,10,11,12]]) ->where(['Pages.snavi_flag' => 1]) ->where(['Pages.display_flag' => 1]) ->where(['Pages.delete_flag' => 0]) ->order(['Pages.sort' => 'ASC']) ->toArray(); if(!empty($tmp_navi2)){ foreach($tmp_navi2 as $row){ $navi_first = []; if($row->parent_id == '0' or $row->parent_id == NULL){ $navi_first['id'] = $row->id; $navi_first['name'] = $row->name; if($row->parent_id == NULL && $row->parent_id != '0'){ $navi_first['slug'] = ''; }else{ if($row->pagetype_id == 11){ $navi_first['slug'] = $row->slug; $navi_first['other1'] = $row->other1; $navi_first['other_flag'] = $row->other_flag; }else{ $navi_first['slug'] = $row->slug.'/'; } } $data['navi']['middle'][] = $navi_first; foreach($tmp_navi2 as $row2){ $navi_second = []; if($row2->parent_id == $row->id){ $navi_second['id'] = $row2->id; $navi_second['name'] = $row2->name; if($row2->pagetype_id == 11){ $navi_second['slug'] = $row2->slug; $navi_second['other1'] = $row2->other1; $navi_second['other_flag'] = $row2->other_flag; }else{ $navi_second['slug'] = $row->slug.'/'.$row2->slug.'/'; } $data['navi']['middle'][] = $navi_second; foreach($tmp_navi2 as $row3){ $navi_third = []; if($row3->parent_id == $row2->id){ $navi_third['id'] = $row3->id; $navi_third['name'] = $row3->name; if($row3->pagetype_id == 11){ $navi_third['slug'] = $row3->slug; $navi_third['other1'] = $row3->other1; $navi_third['other_flag'] = $row3->other_flag; }else{ $navi_third['slug'] = $row->slug.'/'.$row2->slug.'/'.$row3->slug.'/'; } //$navi_second['third'][] = $navi_third; $data['navi']['middle'][] = $navi_third; } } //$navi_first['second'][] = $navi_second; } } //$data['navi']['up'][] = $navi_first; } } } //下部ナビゲーションメニュー /*$tmp_navi3 = $this->Pages->find() ->select(['Pages.parent_id', 'Pages.id', 'Pages.name', 'Pages.slug']) ->where(['Pages.company_id' => $company_id]) //->where(['Pages.pagetype_id IN' => [1,4], ->where(['Pages.pagetype_id IN' => [1,2,3,4], 'OR' => [['Pages.parent_id' => 0], ['Pages.parent_id IS' => NULL]] ]) ->where(['Pages.fnavi_flag' => 1]) ->where(['Pages.display_flag' => 1]) ->where(['Pages.delete_flag' => 0]) ->order(['Pages.sort' => 'ASC']) ->toArray(); if(!empty($tmp_navi3)){ foreach($tmp_navi3 as $row){ $navi_first = []; if($row->parent_id == '0' or $row->parent_id == NULL){ $navi_first['id'] = $row->id; $navi_first['name'] = $row->name; if($row->parent_id == NULL && $row->parent_id != '0'){ $navi_first['slug'] = ''; }else{ $navi_first['slug'] = $row->slug.'/'; } $data['navi']['down'][] = $navi_first; } } }*/ $tmp_navi3 = $this->Pages->find() ->select(['Pages.parent_id', 'Pages.id', 'Pages.name', 'Pages.slug', 'Pages.fnavi_flag', 'Pages.pagetype_id', 'Pages.other1', 'Pages.other_flag']) ->where(['Pages.company_id' => $company_id]) //->where(['Pages.pagetype_id IN' => [1,4]]) //->where(['Pages.pagetype_id IN' => [1,2,3,4,8]]) ->where(['Pages.pagetype_id IN' => [1,2,3,4,5,8,10,11,12]]) //->where(['Pages.fnavi_flag' => 1]) ->where(['Pages.display_flag' => 1]) ->where(['Pages.delete_flag' => 0]) ->order(['Pages.sort' => 'ASC']) ->toArray(); if(!empty($tmp_navi3)){ foreach($tmp_navi3 as $row){ $navi_first = []; if($row->parent_id == '0' or $row->parent_id == NULL){ $navi_first['id'] = $row->id; $navi_first['name'] = $row->name; if($row->parent_id == NULL && $row->parent_id != '0'){ $navi_first['slug'] = ''; }else{ if($row->pagetype_id == 11){ $navi_first['slug'] = $row->slug; $navi_first['other1'] = $row->other1; $navi_first['other_flag'] = $row->other_flag; }else{ $navi_first['slug'] = $row->slug.'/'; } } $navi_first['fnavi_flag'] = $row->fnavi_flag; foreach($tmp_navi3 as $row2){ $navi_second = []; if($row2->parent_id == $row->id){ $navi_second['id'] = $row2->id; $navi_second['name'] = $row2->name; if($row2->pagetype_id == 11){ $navi_second['slug'] = $row2->slug; $navi_second['other1'] = $row2->other1; $navi_second['other_flag'] = $row2->other_flag; }else{ $navi_second['slug'] = $row2->slug.'/'; } $navi_second['fnavi_flag'] = $row2->fnavi_flag; foreach($tmp_navi3 as $row3){ $navi_third = []; if($row3->parent_id == $row2->id){ $navi_third['id'] = $row3->id; $navi_third['name'] = $row3->name; if($row3->pagetype_id == 11){ $navi_third['slug'] = $row3->slug; $navi_third['other1'] = $row3->other1; $navi_third['other_flag'] = $row3->other1; }else{ $navi_third['slug'] = $row3->slug.'/'; } $navi_third['fnavi_flag'] = $row3->fnavi_flag; $navi_second['third'][] = $navi_third; } } $navi_first['second'][] = $navi_second; } } $data['navi']['down'][] = $navi_first; } } } //キャッシュの書き込み ※※※ //Cache::write($company_id.'_navi', $data['navi'], 'page'); } /*if($_SERVER['REMOTE_ADDR'] == '219.113.215.10'){ var_dump('アレス事務所内のみで表示するデバッグ'); var_dump($data['navi']); }*/ return $data['navi']; } public function sub_navi_data($company_id, $navigation_page_id){ if(($data['navi'] = Cache::read($company_id.'_navi', 'page')) === false){ //表示ページが起点ページだった場合、そのデータを取得 //上部ナビゲーションメニュー $tmp_navi = $this->Pages->find() ->select(['Pages.parent_id', 'Pages.id', 'Pages.name', 'Pages.slug', 'Pages.pagetype_id', 'Pages.other1']) ->where(['Pages.company_id' => $company_id]) //->where(['Pages.pagetype_id IN' => [1,4]]) //->where(['Pages.pagetype_id IN' => [1,2,3,4,8]]) ->where(['Pages.pagetype_id IN' => [1,2,3,4,5,8,10,11,12]]) //->where(['Pages.navi_flag' => 1]) ->where(['OR' => [['Pages.navi_flag' => 1], ['Pages.id' => $navigation_page_id]]]) ->where(['Pages.display_flag' => 1]) ->where(['Pages.delete_flag' => 0]) ->order(['Pages.sort' => 'ASC']) ->toArray(); if(!empty($tmp_navi)){ foreach($tmp_navi as $row){ $navi_first = []; //if($row->parent_id == '0' or $row->parent_id == NULL){ if($row->id == $navigation_page_id){ $navi_first['id'] = $row->id; $navi_first['name'] = $row->name; if($row->parent_id == NULL && $row->parent_id != '0'){ $navi_first['slug'] = ''; }elseif($row->parent_id != NULL && $row->parent_id != '0'){ $tmp_parent = $this->Pages->find() ->select(['Pages.parent_id', 'Pages.id', 'Pages.name', 'Pages.slug']) ->where(['Pages.id' => $row->parent_id]) ->where(['Pages.company_id' => $company_id]) ->first(); $navi_first['slug'] = $tmp_parent->slug.'/'.$row->slug.'/'; }else{ if($row->pagetype_id == 11){ $navi_first['slug'] = $row->slug; $navi_first['other1'] = $row->other1; }else{ $navi_first['slug'] = $row->slug.'/'; } } $tmp_slug = $navi_first['slug']; $data['navi']['up'][] = $navi_first; foreach($tmp_navi as $row2){ //$navi_second = []; $navi_first = []; if($row2->parent_id == $row->id){ $navi_first['id'] = $row2->id; $navi_first['name'] = $row2->name; if($row2->pagetype_id == 11){ $navi_first['slug'] = $row2->slug; $navi_first['other1'] = $row2->other1; }else{ $navi_first['slug'] = $tmp_slug.$row2->slug.'/'; } foreach($tmp_navi as $row3){ $navi_second = []; if($row3->parent_id == $row2->id){ $navi_second['id'] = $row3->id; $navi_second['name'] = $row3->name; if($row3->pagetype_id == 11){ $navi_second['slug'] = $row3->slug; $navi_second['other1'] = $row3->other1; }else{ $navi_second['slug'] = $row3->slug.'/'; } $navi_first['second'][] = $navi_second; } } //$navi_first['second'][] = $navi_second; $data['navi']['up'][] = $navi_first; } } //$data['navi']['up'][] = $navi_first; } } } //サイドナビゲーションメニュー $tmp_navi2 = $this->Pages->find() ->select(['Pages.parent_id', 'Pages.id', 'Pages.name', 'Pages.slug', 'Pages.pagetype_id', 'Pages.other1']) ->where(['Pages.company_id' => $company_id]) //->where(['Pages.pagetype_id IN' => [1,4]]) //->where(['Pages.pagetype_id IN' => [1,2,3,4,8]]) ->where(['Pages.pagetype_id IN' => [1,2,3,4,5,8,10,11,12]]) ->where(['Pages.snavi_flag' => 1]) ->where(['Pages.display_flag' => 1]) ->where(['Pages.delete_flag' => 0]) ->order(['Pages.sort' => 'ASC']) ->toArray(); if(!empty($tmp_navi2)){ foreach($tmp_navi2 as $row){ $navi_first = []; //if($row->parent_id == '0' or $row->parent_id == NULL){ if($row->id == $navigation_page_id){ $navi_first['id'] = $row->id; $navi_first['name'] = $row->name; if($row->parent_id == NULL && $row->parent_id != '0'){ $navi_first['slug'] = ''; }elseif($row->parent_id != NULL && $row->parent_id != '0'){ $tmp_parent = $this->Pages->find() ->select(['Pages.parent_id', 'Pages.id', 'Pages.name', 'Pages.slug']) ->where(['Pages.id' => $row->parent_id]) ->where(['Pages.company_id' => $company_id]) ->first(); $navi_first['slug'] = $tmp_parent->slug.'/'.$row->slug.'/'; }else{ if($row->pagetype_id == 11){ $navi_first['slug'] = $row->slug; $navi_first['other1'] = $row->other1; }else{ $navi_first['slug'] = $row->slug.'/'; } } $tmp_slug = $navi_first['slug']; $data['navi']['middle'][] = $navi_first; foreach($tmp_navi2 as $row2){ $navi_second = []; if($row2->parent_id == $row->id){ $navi_second['id'] = $row2->id; $navi_second['name'] = $row2->name; if($row2->pagetype_id == 11){ $navi_second['slug'] = $row2->slug; $navi_second['other1'] = $row2->other1; }else{ $navi_second['slug'] = $tmp_slug.'/'.$row2->slug.'/'; } $data['navi']['middle'][] = $navi_second; foreach($tmp_navi2 as $row3){ $navi_third = []; if($row3->parent_id == $row2->id){ $navi_third['id'] = $row3->id; $navi_third['name'] = $row3->name; if($row3->pagetype_id == 11){ $navi_third['slug'] = $row3->slug; $navi_third['other1'] = $row3->other1; }else{ $navi_third['slug'] = $row3->slug.'/'; } //$navi_second['third'][] = $navi_third; $data['navi']['middle'][] = $navi_third; } } //$navi_first['second'][] = $navi_second; } } //$data['navi']['up'][] = $navi_first; } } } //下部ナビゲーションメニュー $tmp_navi3 = $this->Pages->find() ->select(['Pages.parent_id', 'Pages.id', 'Pages.name', 'Pages.slug', 'Pages.fnavi_flag', 'Pages.pagetype_id', 'Pages.other1']) ->where(['Pages.company_id' => $company_id]) //->where(['Pages.pagetype_id IN' => [1,4]]) //->where(['Pages.pagetype_id IN' => [1,2,3,4,8]]) ->where(['Pages.pagetype_id IN' => [1,2,3,4,5,8,10,11,12]]) //->where(['Pages.fnavi_flag' => 1]) ->where(['Pages.display_flag' => 1]) ->where(['Pages.delete_flag' => 0]) ->order(['Pages.sort' => 'ASC']) ->toArray(); if(!empty($tmp_navi3)){ foreach($tmp_navi3 as $row){ $navi_first = []; //if($row->parent_id == '0' or $row->parent_id == NULL){ if($row->id == $navigation_page_id){ $navi_first['id'] = $row->id; $navi_first['name'] = $row->name; if($row->parent_id == NULL && $row->parent_id != '0'){ $navi_first['slug'] = ''; }elseif($row->parent_id != NULL && $row->parent_id != '0'){ $tmp_parent = $this->Pages->find() ->select(['Pages.parent_id', 'Pages.id', 'Pages.name', 'Pages.slug']) ->where(['Pages.id' => $row->parent_id]) ->where(['Pages.company_id' => $company_id]) ->first(); $navi_first['slug'] = $tmp_parent->slug.'/'.$row->slug.'/'; }else{ if($row->pagetype_id == 11){ $navi_first['slug'] = $row->slug; $navi_first['other1'] = $row->other1; }else{ $navi_first['slug'] = $row->slug.'/'; } } $navi_first['fnavi_flag'] = $row->fnavi_flag; $tmp_slug = $navi_first['slug']; foreach($tmp_navi3 as $row2){ $navi_second = []; if($row2->parent_id == $row->id){ $navi_second['id'] = $row2->id; $navi_second['name'] = $row2->name; if($row2->pagetype_id == 11){ $navi_second['slug'] = $row2->slug; $navi_second['other1'] = $row2->other1; }else{ $navi_second['slug'] = $row2->slug.'/'; } $navi_second['fnavi_flag'] = $row2->fnavi_flag; foreach($tmp_navi3 as $row3){ $navi_third = []; if($row3->parent_id == $row2->id){ $navi_third['id'] = $row3->id; $navi_third['name'] = $row3->name; if($row3->pagetype_id == 11){ $navi_third['slug'] = $row3->slug; $navi_third['other1'] = $row3->other1; }else{ $navi_third['slug'] = $row3->slug.'/'; } $navi_third['fnavi_flag'] = $row3->fnavi_flag; $navi_second['third'][] = $navi_third; } } $navi_first['second'][] = $navi_second; } } $data['navi']['down'][] = $navi_first; } } } //キャッシュの書き込み ※※※ //Cache::write($company_id.'_navi', $data['navi'], 'page'); } /*if($_SERVER['REMOTE_ADDR'] == '219.113.215.10'){ var_dump('アレス事務所内のみで表示するデバッグ'); var_dump($data['navi']); }*/ return $data['navi']; } public function new_navi_data($company_id, $mode = null){ if(($data['navi'] = Cache::read($company_id.'_navi', 'page')) === false){ //上部ナビゲーションメニュー $tmp_navi = $this->Newpages->find() ->select(['Newpages.parent_id', 'Newpages.id', 'Newpages.pagetype_id', 'Newpages.name', 'Newpages.slug', 'Newpages.slug_plus', 'Newpages.link', 'Newpages.pagetype_id', 'Newpages.other_flag']) ->where(['Newpages.company_id' => $company_id]) ->where(['Newpages.pagetype_id IN' => [1,2,3,4,5,8,9,10,11,12,13,14,15]]) ->where(['Newpages.navi_flag' => 1]) ->where(['Newpages.display_flag' => 1]) ->where(['Newpages.delete_flag' => 0]) ->order(['Newpages.sort' => 'ASC']) ->toArray(); if($mode == 'tmp'){ if(!empty($tmp_navi)){ foreach($tmp_navi as $row){ $navi_first = []; if($row->parent_id == '0' or $row->parent_id == NULL){ $navi_first['id'] = $row->id; $navi_first['name'] = $row->name; //if($row->parent_id == NULL && $row->parent_id != '0'){ if($row->pagetype_id == 1){ $navi_first['slug'] = ''; }else{ if($row->pagetype_id == 11){ $navi_first['slug'] = ltrim($row->link, '/'); $navi_first['other1'] = $row->link; $navi_first['other_flag'] = $row->other_flag; }else{ $navi_first['slug'] = $row->slug.'/'; } } foreach($tmp_navi as $row2){ $navi_second = []; if($row2->parent_id == $row->id){ $navi_second['id'] = $row2->id; $navi_second['name'] = $row2->name; if($row2->pagetype_id == 11){ $navi_second['slug'] = ltrim($row2->link, '/'); $navi_second['other1'] = $row2->link; $navi_second['other_flag'] = $row2->other_flag; }else{ $navi_second['slug'] = $row2->slug.'/'; } foreach($tmp_navi as $row3){ $navi_third = []; if($row3->parent_id == $row2->id){ $navi_third['id'] = $row3->id; $navi_third['name'] = $row3->name; if($row3->pagetype_id == 11){ $navi_third['slug'] = ltrim($row3->link, '/'); $navi_third['other1'] = $row3->link; $navi_third['other_flag'] = $row3->other_flag; }else{ $navi_third['slug'] = $row3->slug; } $navi_second['third'][] = $navi_third; } } $navi_first['second'][] = $navi_second; } } $data['navi']['up'][] = $navi_first; } } } //サイドナビゲーションメニュー $tmp_navi2 = $this->Newpages->find() ->select(['Newpages.parent_id', 'Newpages.id', 'Newpages.name', 'Newpages.slug', 'Newpages.slug_plus', 'Newpages.link', 'Newpages.pagetype_id', 'Newpages.other_flag']) ->where(['Newpages.company_id' => $company_id]) ->where(['Newpages.pagetype_id IN' => [1,2,3,4,5,8,9,10,11,12,13,14,15]]) ->where(['Newpages.snavi_flag' => 1]) ->where(['Newpages.display_flag' => 1]) ->where(['Newpages.delete_flag' => 0]) ->order(['Newpages.sort' => 'ASC']) ->toArray(); if(!empty($tmp_navi2)){ foreach($tmp_navi2 as $row){ $navi_first = []; if($row->parent_id == '0' or $row->parent_id == NULL){ $navi_first['id'] = $row->id; $navi_first['name'] = $row->name; if($row->parent_id == NULL && $row->parent_id != '0'){ $navi_first['slug'] = '/'; }else{ if($row->pagetype_id == 11){ $navi_first['slug'] = $row->slug; $navi_first['other1'] = $row->link; $navi_first['other_flag'] = $row->other_flag; }else{ $navi_first['slug'] = $row->slug_plus; } } $data['navi']['middle'][] = $navi_first; foreach($tmp_navi2 as $row2){ $navi_second = []; if($row2->parent_id == $row->id){ $navi_second['id'] = $row2->id; $navi_second['name'] = $row2->name; if($row2->pagetype_id == 11){ $navi_second['slug'] = $row2->slug; $navi_second['other1'] = $row2->link; $navi_second['other_flag'] = $row2->other_flag; }else{ $navi_second['slug'] = $row2->slug_plus; } $data['navi']['middle'][] = $navi_second; foreach($tmp_navi2 as $row3){ $navi_third = []; if($row3->parent_id == $row2->id){ $navi_third['id'] = $row3->id; $navi_third['name'] = $row3->name; if($row3->pagetype_id == 11){ $navi_third['slug'] = $row3->slug; $navi_third['other1'] = $row3->link; $navi_third['other_flag'] = $row3->other_flag; }else{ $navi_third['slug'] = $row3->slug_plus; } //$navi_second['third'][] = $navi_third; $data['navi']['middle'][] = $navi_third; } } } } } } } // $tmp_navi3 = $this->Newpages->find() ->select(['Newpages.parent_id', 'Newpages.id', 'Newpages.name', 'Newpages.slug', 'Newpages.slug_plus', 'Newpages.link', 'Newpages.fnavi_flag', 'Newpages.pagetype_id', 'Newpages.other_flag']) ->where(['Newpages.company_id' => $company_id]) //->where(['Newpages.pagetype_id IN' => [1,4]]) //->where(['Newpages.pagetype_id IN' => [1,2,3,4,8]]) ->where(['Newpages.pagetype_id IN' => [1,2,3,4,5,8,9,10,11,12,13,14,15]]) //->where(['Newpages.fnavi_flag' => 1]) ->where(['Newpages.display_flag' => 1]) ->where(['Newpages.delete_flag' => 0]) ->order(['Newpages.sort' => 'ASC']) ->toArray(); if(!empty($tmp_navi3)){ foreach($tmp_navi3 as $row){ $navi_first = []; if($row->parent_id == '0' or $row->parent_id == NULL){ $navi_first['id'] = $row->id; $navi_first['name'] = $row->name; //if($row->parent_id == NULL && $row->parent_id != '0'){ if($row->pagetype_id == 1){ $navi_first['slug'] = '/'; }else{ if($row->pagetype_id == 11){ $navi_first['slug'] = ltrim($row->link, '/'); $navi_first['other1'] = $row->link; $navi_first['other_flag'] = $row->other_flag; }else{ $navi_first['slug'] = $row->slug.'/'; } } $navi_first['fnavi_flag'] = $row->fnavi_flag; foreach($tmp_navi3 as $row2){ $navi_second = []; if($row2->parent_id == $row->id){ $navi_second['id'] = $row2->id; $navi_second['name'] = $row2->name; if($row2->pagetype_id == 11){ $navi_second['slug'] = ltrim($row2->link, '/'); $navi_second['other1'] = $row2->link; $navi_second['other_flag'] = $row2->other_flag; }else{ $navi_second['slug'] = $row2->slug.'/'; } $navi_second['fnavi_flag'] = $row2->fnavi_flag; foreach($tmp_navi3 as $row3){ $navi_third = []; if($row3->parent_id == $row2->id){ $navi_third['id'] = $row3->id; $navi_third['name'] = $row3->name; if($row3->pagetype_id == 11){ $navi_third['slug'] = ltrim($row3->link, '/'); $navi_third['other1'] = $row3->link; $navi_third['other_flag'] = $row3->other_flag; }else{ $navi_third['slug'] = $row3->slug.'/'; } $navi_third['fnavi_flag'] = $row3->fnavi_flag; $navi_second['third'][] = $navi_third; } } $navi_first['second'][] = $navi_second; } } $data['navi']['down'][] = $navi_first; } } } }else{ if(!empty($tmp_navi)){ foreach($tmp_navi as $row){ $navi_first = []; if($row->parent_id == '0' or $row->parent_id == NULL){ $navi_first['id'] = $row->id; $navi_first['name'] = $row->name; if($row->parent_id == NULL && $row->parent_id != '0'){ $navi_first['slug'] = '/'; }else{ if($row->pagetype_id == 11){ $navi_first['slug'] = $row->slug; $navi_first['other1'] = $row->link; $navi_first['other_flag'] = $row->other_flag; }else{ $navi_first['slug'] = $row->slug_plus; } } foreach($tmp_navi as $row2){ $navi_second = []; if($row2->parent_id == $row->id){ $navi_second['id'] = $row2->id; $navi_second['name'] = $row2->name; if($row2->pagetype_id == 11){ $navi_second['slug'] = $row2->slug; $navi_second['other1'] = $row2->link; $navi_second['other_flag'] = $row2->other_flag; }else{ $navi_second['slug'] = $row2->slug_plus; } foreach($tmp_navi as $row3){ $navi_third = []; if($row3->parent_id == $row2->id){ $navi_third['id'] = $row3->id; $navi_third['name'] = $row3->name; if($row3->pagetype_id == 11){ $navi_third['slug'] = $row3->slug; $navi_third['other1'] = $row3->link; $navi_third['other_flag'] = $row3->other_flag; }else{ $navi_third['slug'] = $row3->slug_plus; } $navi_second['third'][] = $navi_third; } } $navi_first['second'][] = $navi_second; } } $data['navi']['up'][] = $navi_first; } } } //サイドナビゲーションメニュー $tmp_navi2 = $this->Newpages->find() ->select(['Newpages.parent_id', 'Newpages.id', 'Newpages.name', 'Newpages.slug', 'Newpages.slug_plus', 'Newpages.link', 'Newpages.pagetype_id', 'Newpages.other_flag']) ->where(['Newpages.company_id' => $company_id]) ->where(['Newpages.pagetype_id IN' => [1,2,3,4,5,8,9,10,11,12,13,14,15]]) ->where(['Newpages.snavi_flag' => 1]) ->where(['Newpages.display_flag' => 1]) ->where(['Newpages.delete_flag' => 0]) ->order(['Newpages.sort' => 'ASC']) ->toArray(); if(!empty($tmp_navi2)){ foreach($tmp_navi2 as $row){ $navi_first = []; if($row->parent_id == '0' or $row->parent_id == NULL){ $navi_first['id'] = $row->id; $navi_first['name'] = $row->name; if($row->parent_id == NULL && $row->parent_id != '0'){ $navi_first['slug'] = '/'; }else{ if($row->pagetype_id == 11){ $navi_first['slug'] = $row->slug; $navi_first['other1'] = $row->link; $navi_first['other_flag'] = $row->other_flag; }else{ $navi_first['slug'] = $row->slug_plus; } } $data['navi']['middle'][] = $navi_first; foreach($tmp_navi2 as $row2){ $navi_second = []; if($row2->parent_id == $row->id){ $navi_second['id'] = $row2->id; $navi_second['name'] = $row2->name; if($row2->pagetype_id == 11){ $navi_second['slug'] = $row2->slug; $navi_second['other1'] = $row2->link; $navi_second['other_flag'] = $row2->other_flag; }else{ $navi_second['slug'] = $row2->slug_plus; } $data['navi']['middle'][] = $navi_second; foreach($tmp_navi2 as $row3){ $navi_third = []; if($row3->parent_id == $row2->id){ $navi_third['id'] = $row3->id; $navi_third['name'] = $row3->name; if($row3->pagetype_id == 11){ $navi_third['slug'] = $row3->slug; $navi_third['other1'] = $row3->link; $navi_third['other_flag'] = $row3->other_flag; }else{ $navi_third['slug'] = $row3->slug_plus; } //$navi_second['third'][] = $navi_third; $data['navi']['middle'][] = $navi_third; } } } } } } } // $tmp_navi3 = $this->Newpages->find() ->select(['Newpages.parent_id', 'Newpages.id', 'Newpages.name', 'Newpages.slug', 'Newpages.slug_plus', 'Newpages.link', 'Newpages.fnavi_flag', 'Newpages.pagetype_id', 'Newpages.other_flag']) ->where(['Newpages.company_id' => $company_id]) //->where(['Newpages.pagetype_id IN' => [1,4]]) //->where(['Newpages.pagetype_id IN' => [1,2,3,4,8]]) ->where(['Newpages.pagetype_id IN' => [1,2,3,4,5,8,9,10,11,12,13,14,15]]) //->where(['Newpages.fnavi_flag' => 1]) ->where(['Newpages.display_flag' => 1]) ->where(['Newpages.delete_flag' => 0]) ->order(['Newpages.sort' => 'ASC']) ->toArray(); if(!empty($tmp_navi3)){ foreach($tmp_navi3 as $row){ $navi_first = []; if($row->parent_id == '0' or $row->parent_id == NULL){ $navi_first['id'] = $row->id; $navi_first['name'] = $row->name; if($row->parent_id == NULL && $row->parent_id != '0'){ $navi_first['slug'] = '/'; }else{ if($row->pagetype_id == 11){ $navi_first['slug'] = $row->slug; $navi_first['other1'] = $row->link; $navi_first['other_flag'] = $row->other_flag; }else{ $navi_first['slug'] = $row->slug_plus; } } $navi_first['fnavi_flag'] = $row->fnavi_flag; foreach($tmp_navi3 as $row2){ $navi_second = []; if($row2->parent_id == $row->id){ $navi_second['id'] = $row2->id; $navi_second['name'] = $row2->name; if($row2->pagetype_id == 11){ $navi_second['slug'] = $row2->slug; $navi_second['other1'] = $row2->link; $navi_second['other_flag'] = $row2->other_flag; }else{ $navi_second['slug'] = $row2->slug_plus; } $navi_second['fnavi_flag'] = $row2->fnavi_flag; foreach($tmp_navi3 as $row3){ $navi_third = []; if($row3->parent_id == $row2->id){ $navi_third['id'] = $row3->id; $navi_third['name'] = $row3->name; if($row3->pagetype_id == 11){ $navi_third['slug'] = $row3->slug; $navi_third['other1'] = $row3->link; $navi_third['other_flag'] = $row3->other_flag; }else{ $navi_third['slug'] = $row3->slug_plus; } $navi_third['fnavi_flag'] = $row3->fnavi_flag; $navi_second['third'][] = $navi_third; } } $navi_first['second'][] = $navi_second; } } $data['navi']['down'][] = $navi_first; } } } } //キャッシュの書き込み ※※※ //Cache::write($company_id.'_navi', $data['navi'], 'page'); } return $data['navi']; } public function new_sub_navi_data($company_id, $navigation_page_id){ if(($data['navi'] = Cache::read($company_id.'_navi', 'page')) === false){ //上部ナビゲーションメニュー $tmp_navi = $this->Newpages->find() ->select(['Newpages.parent_id', 'Newpages.id', 'Newpages.pagetype_id', 'Newpages.name', 'Newpages.slug', 'Newpages.slug_plus', 'Newpages.link', 'Newpages.pagetype_id']) ->where(['Newpages.company_id' => $company_id]) ->where(['Newpages.pagetype_id IN' => [1,2,3,4,5,8,9,10,11,12,13,14,15]]) //->where(['Newpages.navi_flag' => 1]) ->where(['OR' => [['Newpages.navi_flag' => 1], ['Newpages.id' => $navigation_page_id]]]) ->where(['Newpages.display_flag' => 1]) ->where(['Newpages.delete_flag' => 0]) ->order(['Newpages.sort' => 'ASC']) ->toArray(); // if(!empty($tmp_navi)){ foreach($tmp_navi as $row){ $navi_first = []; //if($row->parent_id == '0' or $row->parent_id == NULL){ if($row->id == $navigation_page_id){ $navi_first['id'] = $row->id; $navi_first['name'] = $row->name; if($row->parent_id == NULL && $row->parent_id != '0'){ $navi_first['slug'] = '/'; }elseif($row->parent_id != NULL && $row->parent_id != '0'){ $tmp_parent = $this->Newpages->find() ->select(['Newpages.parent_id', 'Newpages.id', 'Newpages.pagetype_id', 'Newpages.name', 'Newpages.slug', 'Newpages.slug_plus', 'Newpages.link', 'Newpages.pagetype_id']) ->where(['Newpages.id' => $row->parent_id]) ->where(['Newpages.company_id' => $company_id]) ->first(); $navi_first['slug'] = $tmp_parent->slug.'/'.$row->slug.'/'; }else{ if($row->pagetype_id == 11){ $navi_first['slug'] = $row->slug; $navi_first['other1'] = $row->link; }else{ $navi_first['slug'] = $row->slug_plus; } } $data['navi']['up'][] = $navi_first; foreach($tmp_navi as $row2){ //$navi_second = []; $navi_first = []; if($row2->parent_id == $row->id){ $navi_first['id'] = $row2->id; $navi_first['name'] = $row2->name; if($row2->pagetype_id == 11){ $navi_first['slug'] = $row2->slug; $navi_first['other1'] = $row2->link; }else{ $navi_first['slug'] = $row2->slug_plus; } foreach($tmp_navi as $row3){ $navi_second = []; if($row3->parent_id == $row2->id){ $navi_second['id'] = $row3->id; $navi_second['name'] = $row3->name; if($row3->pagetype_id == 11){ $navi_second['slug'] = $row3->slug; $navi_second['other1'] = $row3->link; }else{ $navi_second['slug'] = $row3->slug_plus; } $navi_first['second'][] = $navi_second; } } //$navi_first['second'][] = $navi_second; $data['navi']['up'][] = $navi_first; } } //$data['navi']['up'][] = $navi_first; } } } //サイドナビゲーションメニュー $tmp_navi2 = $this->Newpages->find() ->select(['Newpages.parent_id', 'Newpages.id', 'Newpages.name', 'Newpages.slug', 'Newpages.slug_plus', 'Newpages.link', 'Newpages.pagetype_id']) ->where(['Newpages.company_id' => $company_id]) ->where(['Newpages.pagetype_id IN' => [1,2,3,4,5,8,9,10,11,12,13,14,15]]) ->where(['Newpages.snavi_flag' => 1]) ->where(['Newpages.display_flag' => 1]) ->where(['Newpages.delete_flag' => 0]) ->order(['Newpages.sort' => 'ASC']) ->toArray(); if(!empty($tmp_navi2)){ foreach($tmp_navi2 as $row){ $navi_first = []; //if($row->parent_id == '0' or $row->parent_id == NULL){ if($row->id == $navigation_page_id){ $navi_first['id'] = $row->id; $navi_first['name'] = $row->name; if($row->parent_id == NULL && $row->parent_id != '0'){ $navi_first['slug'] = '/'; }elseif($row->parent_id != NULL && $row->parent_id != '0'){ $tmp_parent = $this->Newpages->find() ->select(['Newpages.parent_id', 'Newpages.id', 'Newpages.name', 'Newpages.slug', 'Newpages.slug_plus', 'Newpages.link', 'Newpages.pagetype_id']) ->where(['Newpages.id' => $row->parent_id]) ->where(['Newpages.company_id' => $company_id]) ->first(); $navi_first['slug'] = $tmp_parent->slug.'/'.$row->slug.'/'; }else{ if($row->pagetype_id == 11){ $navi_first['slug'] = $row->slug; $navi_first['other1'] = $row->link; }else{ $navi_first['slug'] = $row->slug_plus; } } $data['navi']['middle'][] = $navi_first; foreach($tmp_navi2 as $row2){ $navi_second = []; if($row2->parent_id == $row->id){ $navi_second['id'] = $row2->id; $navi_second['name'] = $row2->name; if($row2->pagetype_id == 11){ $navi_second['slug'] = $row2->slug; $navi_second['other1'] = $row2->link; }else{ $navi_second['slug'] = $row2->slug_plus; } $data['navi']['middle'][] = $navi_second; foreach($tmp_navi2 as $row3){ $navi_third = []; if($row3->parent_id == $row2->id){ $navi_third['id'] = $row3->id; $navi_third['name'] = $row3->name; if($row3->pagetype_id == 11){ $navi_third['slug'] = $row3->slug; $navi_third['other1'] = $row3->link; }else{ $navi_third['slug'] = $row3->slug_plus; } //$navi_second['third'][] = $navi_third; $data['navi']['middle'][] = $navi_third; } } } } } } } // $tmp_navi3 = $this->Newpages->find() ->select(['Newpages.parent_id', 'Newpages.id', 'Newpages.name', 'Newpages.slug', 'Newpages.slug_plus', 'Newpages.link', 'Newpages.fnavi_flag', 'Newpages.pagetype_id']) ->where(['Newpages.company_id' => $company_id]) //->where(['Newpages.pagetype_id IN' => [1,4]]) //->where(['Newpages.pagetype_id IN' => [1,2,3,4,8]]) ->where(['Newpages.pagetype_id IN' => [1,2,3,4,5,8,9,10,11,12,13,14,15]]) //->where(['Newpages.fnavi_flag' => 1]) ->where(['Newpages.display_flag' => 1]) ->where(['Newpages.delete_flag' => 0]) ->order(['Newpages.sort' => 'ASC']) ->toArray(); if(!empty($tmp_navi3)){ foreach($tmp_navi3 as $row){ $navi_first = []; //if($row->parent_id == '0' or $row->parent_id == NULL){ if($row->id == $navigation_page_id){ $navi_first['id'] = $row->id; $navi_first['name'] = $row->name; if($row->parent_id == NULL && $row->parent_id != '0'){ $navi_first['slug'] = '/'; }else{ if($row->pagetype_id == 11){ $navi_first['slug'] = $row->slug; $navi_first['other1'] = $row->link; }else{ $navi_first['slug'] = $row->slug_plus; } } $navi_first['fnavi_flag'] = $row->fnavi_flag; foreach($tmp_navi3 as $row2){ $navi_second = []; if($row2->parent_id == $row->id){ $navi_second['id'] = $row2->id; $navi_second['name'] = $row2->name; if($row2->pagetype_id == 11){ $navi_second['slug'] = $row2->slug; $navi_second['other1'] = $row2->link; }else{ $navi_second['slug'] = $row2->slug_plus; } $navi_second['fnavi_flag'] = $row2->fnavi_flag; foreach($tmp_navi3 as $row3){ $navi_third = []; if($row3->parent_id == $row2->id){ $navi_third['id'] = $row3->id; $navi_third['name'] = $row3->name; if($row3->pagetype_id == 11){ $navi_third['slug'] = $row3->slug; $navi_third['other1'] = $row3->link; }else{ $navi_third['slug'] = $row3->slug_plus; } $navi_third['fnavi_flag'] = $row3->fnavi_flag; $navi_second['third'][] = $navi_third; } } $navi_first['second'][] = $navi_second; } } $data['navi']['down'][] = $navi_first; } } } //キャッシュの書き込み ※※※ //Cache::write($company_id.'_navi', $data['navi'], 'page'); } return $data['navi']; } public function sitemap_data($company_id){ if(($data['sitemap'] = Cache::read($company_id.'_sitemap', 'page')) === false){ //ナビゲーションメニュー $tmp_sitemap = $this->Pages->find() ->select(['Pages.parent_id', 'Pages.id', 'Pages.name', 'Pages.slug', 'Pages.pagetype_id', 'Pages.other1']) ->where(['Pages.company_id' => $company_id]) //->where(['Pages.pagetype_id IN' => [1,4]]) //->where(['Pages.pagetype_id IN' => [1,2,3,4,8]]) ->where(['Pages.pagetype_id IN' => [1,2,3,4,5,8,9,10,11,12,13,14]]) ->where(['Pages.sitemap_flag' => 1]) ->where(['Pages.display_flag' => 1]) ->where(['Pages.delete_flag' => 0]) ->order(['Pages.sort' => 'ASC']) ->toArray(); if(!empty($tmp_sitemap)){ foreach($tmp_sitemap as $row){ $sitemap_first = []; if($row->parent_id == '0' or $row->parent_id == NULL){ $sitemap_first['id'] = $row->id; $sitemap_first['name'] = $row->name; if($row->parent_id == NULL && $row->parent_id != '0'){ $sitemap_first['slug'] = ''; }else{ if($row->pagetype_id == 11){ $sitemap_first['slug'] = $row->slug; $sitemap_first['other1'] = $row->other1; }else{ $sitemap_first['slug'] = $row->slug.'/'; } } foreach($tmp_sitemap as $row2){ $sitemap_second = []; if($row2->parent_id == $row->id){ $sitemap_second['id'] = $row2->id; $sitemap_second['name'] = $row2->name; if($row2->pagetype_id == 11){ $sitemap_second['slug'] = $row2->slug; $sitemap_second['other1'] = $row2->other1; }else{ $sitemap_second['slug'] = $row2->slug.'/'; } foreach($tmp_sitemap as $row3){ $sitemap_third = []; if($row3->parent_id == $row2->id){ $sitemap_third['id'] = $row3->id; $sitemap_third['name'] = $row3->name; if($row3->pagetype_id == 11){ $sitemap_third['slug'] = $row3->slug; $sitemap_third['other1'] = $row3->other1; }else{ $sitemap_third['slug'] = $row3->slug.'/'; } $sitemap_second['third'][] = $sitemap_third; } } $sitemap_first['second'][] = $sitemap_second; } } $data['sitemap'][] = $sitemap_first; } } } //キャッシュの書き込み ※※※ //Cache::write($company_id.'_navi', $data['navi'], 'page'); } /*if($_SERVER['REMOTE_ADDR'] == '222.224.235.131'){ var_dump('東京本社のみに表示されるデバッグです'); var_dump($data['sitemap']); }*/ return $data['sitemap']; } public function newsitemap_data($company_id){ if(($data['sitemap'] = Cache::read($company_id.'_sitemap', 'page')) === false){ //ナビゲーションメニュー $tmp_sitemap = $this->Newpages->find() ->select(['Newpages.parent_id', 'Newpages.id', 'Newpages.name', 'Newpages.slug', 'Newpages.pagetype_id', 'Newpages.link']) ->where(['Newpages.company_id' => $company_id]) //->where(['Pages.pagetype_id IN' => [1,4]]) //->where(['Pages.pagetype_id IN' => [1,2,3,4,8]]) ->where(['Newpages.pagetype_id IN' => [1,2,3,4,5,8,9,10,11,12,13,14,15]]) ->where(['Newpages.sitemap_flag' => 1]) ->where(['Newpages.display_flag' => 1]) ->where(['Newpages.delete_flag' => 0]) ->order(['Newpages.sort' => 'ASC']) ->toArray(); if(!empty($tmp_sitemap)){ foreach($tmp_sitemap as $row){ $sitemap_first = []; //if($row->parent_id == '0' or $row->parent_id == NULL){ if($row->parent_id == '0' || $row->pagetype_id == 1){ $sitemap_first['id'] = $row->id; $sitemap_first['name'] = $row->name; if($row->parent_id == NULL && $row->parent_id != '0'){ $sitemap_first['slug'] = ''; }else{ if($row->pagetype_id == 11){ $sitemap_first['slug'] = $row->slug; $sitemap_first['other1'] = $row->link; }else{ $sitemap_first['slug'] = $row->slug.'/'; } } foreach($tmp_sitemap as $row2){ $sitemap_second = []; if($row2->parent_id == $row->id){ $sitemap_second['id'] = $row2->id; $sitemap_second['name'] = $row2->name; if($row2->pagetype_id == 11){ $sitemap_second['slug'] = $row2->slug; $sitemap_second['other1'] = $row2->link; }else{ $sitemap_second['slug'] = $row2->slug.'/'; } foreach($tmp_sitemap as $row3){ $sitemap_third = []; if($row3->parent_id == $row2->id){ $sitemap_third['id'] = $row3->id; $sitemap_third['name'] = $row3->name; if($row3->pagetype_id == 11){ $sitemap_third['slug'] = $row3->slug; $sitemap_third['other1'] = $row3->link; }else{ $sitemap_third['slug'] = $row3->slug.'/'; } $sitemap_second['third'][] = $sitemap_third; } } $sitemap_first['second'][] = $sitemap_second; } } $data['sitemap'][] = $sitemap_first; } } } //キャッシュの書き込み ※※※ //Cache::write($company_id.'_navi', $data['navi'], 'page'); } /*if($_SERVER['REMOTE_ADDR'] == '222.224.235.131'){ var_dump('東京本社のみに表示されるデバッグです'); var_dump($data['sitemap']); }*/ return $data['sitemap']; } public function block_data($company_id, $block_order, $fixed_slug, $form_block_id, $mode){ //ページブロック情報取得 if(!empty($block_order)){ $block_array = explode(',', $block_order); //formの確認画面や完了画面用の処理 if(($fixed_slug == 'form_conf' || $fixed_slug == 'form_send') && in_array($form_block_id, $block_array)){ $block_array = explode(',', $form_block_id); }elseif($fixed_slug == 'form_conf' || $fixed_slug == 'form_send'){ $data['blocks'] = ''; $data['block_other'] = ''; return $data; } //$block_array = explode(',', $block_order); $data['blocks'] = $this->Blocks->find() //※※※後で絞込精査 //->select(['Pages.id', 'Pages.pagetype_id', 'Pages.parent_id', 'Pages.name', 'Pages.slug', 'Pages.title', 'Pages.sort', 'Pagetypes.id', 'Pagetypes.name']) //->contain(['BlockDetails']) ->where(['Blocks.id IN' => $block_array]) ->where(['Blocks.company_id' => $company_id]) ->where(['Blocks.delete_flag' => 0]) ->order([ 'FIELD(Blocks.id, '.$block_order.') ASC', ]) //->order(['Blocks.id' => $block_array]) ->all(); } //blockに紐付くデータ取得 $data['block_other'] = []; if(isset($data['blocks']) && !$data['blocks']->isEmpty()){ //if(isset($data['blocks']) && !empty($data['blocks'])){ foreach($data['blocks'] as $block){ if($block->blocktype == 'block_blog' || $block->blocktype == 'block_blog2' || $block->blocktype == 'block_blog3' || $block->blocktype == 'block_blog4' || $block->blocktype == 'block_blog5'){ $page_kind = str_replace('block_blog', '', $block->blocktype); $parent_query = $this->Pages->find() ->where(['Pages.id' => $block->other3]) ->where(['Pages.company_id' => $company_id]) ->where(['Pages.delete_flag' => 0]); //->first(); if(!empty($page_kind)){ $parent_query->where(['Pages.page_kind' => $page_kind]); }else{ $parent_query->where(['OR' => [['Pages.page_kind' => ''], ['Pages.page_kind IS NULL']]]); } $data['block_other']['blog'][$block->id]['parent'] = $parent_query->first(); $query = $this->Pages->find() ->where(['Pages.company_id' => $company_id]) ->where(['Pages.parent_id' => $block->other3]) ->where(['Pages.display_flag' => 1]) ->where(['Pages.delete_flag' => 0]) ->where(['Pages.release_date <=' => date('Y-m-d H:i:s')]) ->order(['Pages.release_date' => 'DESC']); $tmp_sql_category = $block->text2; if(!empty($tmp_sql_category)){ $query->matching('BlogCategories', function($q)use($tmp_sql_category) { //return $q->where(['BlogCategories.slug' => $tag_category]); return $q->where(['BlogCategories.id IN' => explode(',', $tmp_sql_category)]); }); } $query->distinct(['Pages.id']); if(!empty($block->other1) && $block->other1 != '-1'){ $query->limit($block->other1); } $children = $query->all(); $data['block_other']['blog'][$block->id]['children'] = $children; }elseif($block->blocktype == 'block_news' || $block->blocktype == 'block_news2' || $block->blocktype == 'block_news3' || $block->blocktype == 'block_news4' || $block->blocktype == 'block_news5'){ $page_kind = str_replace('block_news', '', $block->blocktype); $parent_query = $this->Pages->find() ->where(['Pages.id' => $block->other3]) ->where(['Pages.company_id' => $company_id]) ->where(['Pages.delete_flag' => 0]); //->first(); if(!empty($page_kind)){ $parent_query->where(['Pages.page_kind' => $page_kind]); }else{ $parent_query->where(['OR' => [['Pages.page_kind' => ''], ['Pages.page_kind IS NULL']]]); } $data['block_other']['news'][$block->id]['parent'] = $parent_query->first(); $query = $this->Pages->find() ->where(['Pages.company_id' => $company_id]) ->where(['Pages.parent_id' => $block->other3]) ->where(['Pages.display_flag' => 1]) ->where(['Pages.delete_flag' => 0]) ->where(['Pages.release_date <=' => date('Y-m-d H:i:s')]) ->order(['Pages.release_date' => 'DESC']); $tmp_sql_category = $block->text2; if(!empty($tmp_sql_category)){ $query->matching('NewsCategories', function($q)use($tmp_sql_category) { //return $q->where(['NewsCategories.slug' => $tag_category]); return $q->where(['NewsCategories.id IN' => explode(',', $tmp_sql_category)]); }); } $query->distinct(['Pages.id']); if(!empty($block->other1) && $block->other1 != '-1'){ $query->limit($block->other1); } $children = $query->all(); $data['block_other']['news'][$block->id]['children'] = $children; }elseif($block->blocktype == 'block_column' || $block->blocktype == 'block_column2' || $block->blocktype == 'block_column3' || $block->blocktype == 'block_column4' || $block->blocktype == 'block_column5'){ $page_kind = str_replace('block_column', '', $block->blocktype); $parent_query = $this->Pages->find() ->where(['Pages.id' => $block->other3]) ->where(['Pages.company_id' => $company_id]) ->where(['Pages.delete_flag' => 0]); //->first(); if(!empty($page_kind)){ $parent_query->where(['Pages.page_kind' => $page_kind]); }else{ $parent_query->where(['OR' => [['Pages.page_kind' => ''], ['Pages.page_kind IS NULL']]]); } $data['block_other']['column'][$block->id]['parent'] = $parent_query->first(); $query = $this->Pages->find() ->where(['Pages.company_id' => $company_id]) ->where(['Pages.parent_id' => $block->other3]) ->where(['Pages.display_flag' => 1]) ->where(['Pages.delete_flag' => 0]) ->where(['Pages.release_date <=' => date('Y-m-d H:i:s')]) ->order(['Pages.release_date' => 'DESC']); $tmp_sql_category = $block->text2; if(!empty($tmp_sql_category)){ $query->matching('NewsCategories', function($q)use($tmp_sql_category) { //return $q->where(['NewsCategories.slug' => $tag_category]); return $q->where(['NewsCategories.id IN' => explode(',', $tmp_sql_category)]); }); } $query->distinct(['Pages.id']); if(!empty($block->other1) && $block->other1 != '-1'){ $query->limit($block->other1); } $children = $query->all(); $data['block_other']['column'][$block->id]['children'] = $children; }elseif($block->blocktype == 'block_history'){ //blocks新形式 if($block->tmp_flag == 1){ /*$data['block_other']['history'][$block->block_details[0]->content]['parent'] = $this->Pages->find() ->where(['Pages.id' => $block->block_details[0]->content]) ->where(['Pages.company_id' => $company_id]) ->where(['Pages.delete_flag' => 0]) ->first();*/ $query = $this->Pages->find() ->where(['Pages.company_id' => $company_id]) //->where(['Pages.parent_id' => $block->block_details[0]->content]) ->where(['Pages.display_flag' => 1]) ->where(['Pages.delete_flag' => 0]) ->order(['Pages.modified' => 'DESC']); if(!empty($block->other1) && $block->other1 != '-1'){ $query->limit($block->other1); } $children_org = $query->all(); $children = []; if(!empty($children_org)){ foreach($children_org as $child){ $tmp_child = []; $tmp_child['name'] = $child->name; $tmp_child['slug'] = $child->slug; $tmp_child['created'] = $child->created; $tmp_child['modified'] = $child->modified; $children[] = $tmp_child; } } $data['block_other']['history'][$block->id]['children'] = $children; //blocks旧形式 }else{ /*$data['block_other']['history'][$block->block_details[0]->content]['parent'] = $this->Pages->find() ->where(['Pages.id' => $block->block_details[0]->content]) ->where(['Pages.company_id' => $company_id]) ->where(['Pages.delete_flag' => 0]) ->first();*/ $query = $this->Pages->find() ->where(['Pages.company_id' => $company_id]) //->where(['Pages.parent_id' => $block->block_details[0]->content]) ->where(['Pages.display_flag' => 1]) ->where(['Pages.delete_flag' => 0]) ->order(['Pages.modified' => 'DESC']); if(!empty($block->other1) && $block->other1 != '-1'){ //$query->limit($block->other1); } $query->limit(5); $children = $query->all(); $data['block_other']['history'][$block->block_details[0]->id]['children'] = $children; } }elseif($block->blocktype == 'block_shop'){ //blocks新形式 if($block->tmp_flag == 1){ $data['block_other']['shop'][$block->text1] = $this->Shops->find() ->where(['Shops.id' => $block->text1]) ->where(['Shops.company_id' => $company_id]) ->where(['Shops.delete_flag' => 0]) ->first(); //blocks旧形式 }else{ $data['block_other']['shop'][$block->block_details[0]->content] = $this->Shops->find() ->where(['Shops.id' => $block->block_details[0]->content]) ->where(['Shops.company_id' => $company_id]) ->where(['Shops.delete_flag' => 0]) ->first(); } }elseif($block->blocktype == 'block_recruit'){ //blocks新形式前提で記述 //一覧表示 if($block->other1 == 1){ $data['block_other']['recruit'][$block->id]['child'] = $this->Recruits->find() ->where(['Recruits.company_id' => $company_id]) ->where(['Recruits.display_flag' => 1]) ->where(['Recruits.delete_flag' => 0]) ->limit($block->other2) ->order(['Recruits.sort' => 'ASC']); //パーツ毎のカテゴリ絞り込み if($block->other3 == 2){ $data['block_other']['recruit'][$block->id]['child']->where(['Recruits.recruit_category_id IN' => explode(',', $block->other4)]); } $data['block_other']['recruit'][$block->id]['child']->all(); // $data['block_other']['recruit'][$block->id]['parent'] = $this->Pages->find() ->where(['Pages.company_id' => $company_id]) ->where(['Pages.pagetype_id' => 10]) ->where(['Pages.display_flag' => 1]) ->where(['Pages.delete_flag' => 0]) ->first(); //詳細表示 }else{ $data['block_other']['recruit'][$block->id]['child'] = $this->Recruits->find() ->where(['Recruits.id' => $block->other2]) ->where(['Recruits.company_id' => $company_id]) ->where(['Recruits.display_flag' => 1]) ->where(['Recruits.delete_flag' => 0]) ->first(); // $data['block_other']['recruit'][$block->id]['parent'] = $this->Pages->find() ->where(['Pages.company_id' => $company_id]) ->where(['Pages.pagetype_id' => 10]) ->where(['Pages.display_flag' => 1]) ->where(['Pages.delete_flag' => 0]) ->first(); } }elseif($block->blocktype == 'block_menu'){ //blocks新形式 if($block->tmp_flag == 1){ $menu_id_array = explode(',', $block->text1); foreach($menu_id_array as $key=>$val){ $data['block_other']['menu'][$val]['parent'] = $this->MenuCategories->find() ->where(['MenuCategories.id' => $val]) ->where(['MenuCategories.company_id' => $company_id]) ->where(['MenuCategories.delete_flag' => 0]) ->first(); $data['block_other']['menu'][$val]['children'] = $this->Menus->find() ->where(['Menus.company_id' => $company_id]) ->where(['Menus.menu_category_id' => $val]) ->where(['Menus.display_flag' => 1]) ->where(['Menus.delete_flag' => 0]) ->order(['Menus.sort' => 'ASC']); if($block->other1 != '-1'){ $data['block_other']['menu'][$val]['children']->limit($block->other1); } $data['block_other']['menu'][$val]['children']->all(); } //blocks旧形式 }else{ $menu_id_array = explode(',', $block->block_details[0]->content); foreach($menu_id_array as $key=>$val){ $data['block_other']['menu'][$val]['parent'] = $this->MenuCategories->find() ->where(['MenuCategories.id' => $val]) ->where(['MenuCategories.company_id' => $company_id]) ->where(['MenuCategories.delete_flag' => 0]) ->first(); $data['block_other']['menu'][$val]['children'] = $this->Menus->find() ->where(['Menus.company_id' => $company_id]) ->where(['Menus.menu_category_id' => $val]) ->where(['Menus.display_flag' => 1]) ->where(['Menus.delete_flag' => 0]) ->order(['Menus.sort' => 'ASC']); if($block->block_details[1]->content != '-1'){ $data['block_other']['menu'][$val]['children']->limit($block->block_details[1]->content); } $data['block_other']['menu'][$val]['children']->all(); } } }elseif($block->blocktype == 'block_coupon'){ //blocks新形式 if($block->tmp_flag == 1){ $coupon_id_array = explode(',', $block->text1); foreach($coupon_id_array as $key=>$val){ $data['block_other']['coupon'][$block->id][$val] = $this->Coupons->find() ->where(['Coupons.id' => $val]) ->where(['Coupons.company_id' => $company_id]) ->where(['Coupons.display_flag' => 1]) ->where(['Coupons.delete_flag' => 0]) ->first(); } //blocks旧形式 }else{ $coupon_id_array = explode(',', $block->block_details[0]->content); foreach($coupon_id_array as $key=>$val){ $data['block_other']['coupon'][$val] = $this->Coupons->find() ->where(['Coupons.id' => $val]) ->where(['Coupons.company_id' => $company_id]) ->where(['Coupons.display_flag' => 1]) ->where(['Coupons.delete_flag' => 0]) ->first(); } } }elseif($block->blocktype == 'block_staff'){ //blocks新形式 if($block->tmp_flag == 1){ if($block->other3 == 1){ $staff_id_array = explode(',', $block->text1); foreach($staff_id_array as $key=>$val){ $data['block_other']['staff'][$val]['parent'] = $this->StaffCategories->find() ->where(['StaffCategories.id' => $val]) ->where(['StaffCategories.company_id' => $company_id]) ->where(['StaffCategories.delete_flag' => 0]) ->first(); $data['block_other']['staff'][$val]['children'] = $this->Staffs->find() ->where(['Staffs.company_id' => $company_id]) ->where(['Staffs.staff_category_id' => $val]) ->where(['Staffs.display_flag' => 1]) ->where(['Staffs.delete_flag' => 0]) ->order(['Staffs.sort' => 'ASC']); if($block->other1 != '-1'){ $data['block_other']['staff'][$val]['children']->limit($block->other1); } $data['block_other']['staff'][$val]['children']->all(); } }else{ $data['block_other']['staff_bulk'][$block->id]['children'] = $this->Staffs->find() ->contain(['StaffCategories']) ->where(['Staffs.company_id' => $company_id]) ->where(['Staffs.staff_category_id IN' => explode(',', $block->text1)]) ->where(['Staffs.display_flag' => 1]) ->where(['Staffs.delete_flag' => 0]) ->order(['Staffs.sort' => 'ASC']); if($block->other1 != '-1'){ $data['block_other']['staff_bulk'][$block->id]['children']->limit($block->other1); } $data['block_other']['staff_bulk'][$block->id]['children']->all(); } //blocks旧形式 }else{ $staff_id_array = explode(',', $block->block_details[0]->content); foreach($staff_id_array as $key=>$val){ $data['block_other']['staff'][$val]['parent'] = $this->StaffCategories->find() ->where(['StaffCategories.id' => $val]) ->where(['StaffCategories.company_id' => $company_id]) ->where(['StaffCategories.delete_flag' => 0]) ->first(); $data['block_other']['staff'][$val]['children'] = $this->Staffs->find() ->where(['Staffs.company_id' => $company_id]) ->where(['Staffs.staff_category_id' => $val]) ->where(['Staffs.delete_flag' => 0]) ->order(['Staffs.sort' => 'ASC']); if($block->block_details[1]->content != '-1'){ $data['block_other']['staff'][$val]['children']->limit($block->block_details[1]->content); } $data['block_other']['staff'][$val]['children']->all(); } } }elseif($block->blocktype == 'block_gallery' || $block->blocktype == 'block_gallery2' || $block->blocktype == 'block_gallery3' || $block->blocktype == 'block_gallery4' || $block->blocktype == 'block_gallery5'){ //blocks新形式 if($block->tmp_flag == 1){ //GallerySettings $gallery_kind = str_replace('block_gallery', '', $block->blocktype); $gallery_setting_query = $this->Pages->find() ->select(['Pages.id', 'Pages.slug', 'Pages.other4', 'Pages.sort_flag', 'Pages.display_flag']) ->where(['Pages.pagetype_id' => 8]) ->where(['Pages.company_id' => $company_id]) ->where(['Pages.delete_flag' => 0]); //->first(); if(!empty($gallery_kind)){ $gallery_setting_query->where(['Pages.page_kind' => $gallery_kind]); }else{ $gallery_setting_query->where(['Pages.page_kind is NULL']); $gallery_kind = 1; } $data['block_other']['gallery_setting'][$gallery_kind] = $gallery_setting_query->first(); // if($block->other3 == 1){ $gallery_id_array = explode(',', $block->text1); foreach($gallery_id_array as $key=>$val){ $data['block_other']['gallery'][$val]['parent'] = $this->GalleryCategories->find() ->where(['GalleryCategories.id' => $val]) ->where(['GalleryCategories.company_id' => $company_id]) ->where(['GalleryCategories.delete_flag' => 0]) ->first(); $data['block_other']['gallery'][$val]['children'] = $this->Galleries->find() ->where(['Galleries.company_id' => $company_id]) ->where(['Galleries.gallery_category_id' => $val]) ->where(['Galleries.display_flag' => 1]) ->where(['Galleries.delete_flag' => 0]); //->order(['Galleries.sort' => 'ASC']); //昇順・降順 if($data['block_other']['gallery_setting'][$gallery_kind]->sort_flag == 1){ $data['block_other']['gallery'][$val]['children']->order(['Galleries.sort' => 'DESC']); }else{ $data['block_other']['gallery'][$val]['children']->order(['Galleries.sort' => 'ASC']); } if($block->other1 != '-1'){ $data['block_other']['gallery'][$val]['children']->limit($block->other1); } $data['block_other']['gallery'][$val]['children']->all(); } }else{ $data['block_other']['gallery_bulk'][$block->id]['children'] = $this->Galleries->find() ->where(['Galleries.company_id' => $company_id]) ->where(['Galleries.gallery_category_id IN' => explode(',', $block->text1)]) ->where(['Galleries.display_flag' => 1]) ->where(['Galleries.delete_flag' => 0]); //->order(['Galleries.sort' => 'ASC']); //昇順・降順 if($data['block_other']['gallery_setting'][$gallery_kind]->sort_flag == 1){ $data['block_other']['gallery_bulk'][$block->id]['children']->order(['Galleries.sort' => 'DESC']); }else{ $data['block_other']['gallery_bulk'][$block->id]['children']->order(['Galleries.sort' => 'ASC']); } if($block->other1 != '-1'){ $data['block_other']['gallery_bulk'][$block->id]['children']->limit($block->other1); } $data['block_other']['gallery_bulk'][$block->id]['children']->all(); } //blocks旧形式 }else{ if($block->block_details[0]->alt == 1){ $gallery_id_array = explode(',', $block->block_details[0]->content); foreach($gallery_id_array as $key=>$val){ $data['block_other']['gallery'][$val]['parent'] = $this->GalleryCategories->find() ->where(['GalleryCategories.id' => $val]) ->where(['GalleryCategories.company_id' => $company_id]) ->where(['GalleryCategories.delete_flag' => 0]) ->first(); $data['block_other']['gallery'][$val]['children'] = $this->Galleries->find() ->where(['Galleries.company_id' => $company_id]) ->where(['Galleries.gallery_category_id' => $val]) ->where(['Galleries.display_flag' => 1]) ->where(['Galleries.delete_flag' => 0]) ->order(['Galleries.sort' => 'ASC']); if($block->block_details[1]->content != '-1'){ $data['block_other']['gallery'][$val]['children']->limit($block->block_details[1]->content); } $data['block_other']['gallery'][$val]['children']->all(); } }else{ $data['block_other']['gallery_bulk'][$block->id]['children'] = $this->Galleries->find() ->where(['Galleries.company_id' => $company_id]) ->where(['Galleries.gallery_category_id IN' => explode(',', $block->block_details[0]->content)]) ->where(['Galleries.display_flag' => 1]) ->where(['Galleries.delete_flag' => 0]) ->order(['Galleries.sort' => 'ASC']); if($block->block_details[1]->content != '-1'){ $data['block_other']['gallery_bulk'][$block->id]['children']->limit($block->block_details[1]->content); } $data['block_other']['gallery_bulk'][$block->id]['children']->all(); } } }elseif($block->blocktype == 'block_question'){ //blocks新形式 if($block->tmp_flag == 1){ $question_id_array = explode(',', $block->text1); foreach($question_id_array as $key=>$val){ $data['block_other']['question'][$block->id][$val]['parent'] = $this->QuestionCategories->find() ->where(['QuestionCategories.id' => $val]) ->where(['QuestionCategories.company_id' => $company_id]) ->where(['QuestionCategories.delete_flag' => 0]) ->order(['QuestionCategories.sort' => 'ASC']) ->first(); $data['block_other']['question'][$block->id][$val]['children'] = $this->Questions->find() ->where(['Questions.company_id' => $company_id]) ->where(['Questions.question_category_id' => $val]) ->where(['Questions.display_flag' => 1]) ->where(['Questions.delete_flag' => 0]) ->order(['Questions.sort' => 'ASC']); if($block->other1 != '-1'){ $data['block_other']['question'][$block->id][$val]['children']->limit($block->other1); } $data['block_other']['question'][$block->id][$val]['children']->all(); } //blocks旧形式 }else{ $question_id_array = explode(',', $block->block_details[0]->content); foreach($question_id_array as $key=>$val){ $data['block_other']['question'][$val]['parent'] = $this->QuestionCategories->find() ->where(['QuestionCategories.id' => $val]) ->where(['QuestionCategories.company_id' => $company_id]) ->where(['QuestionCategories.delete_flag' => 0]) ->first(); $data['block_other']['question'][$val]['children'] = $this->Questions->find() ->where(['Questions.company_id' => $company_id]) ->where(['Questions.question_category_id' => $val]) ->where(['Questions.display_flag' => 1]) ->where(['Questions.delete_flag' => 0]) ->order(['Questions.sort' => 'ASC']); if($block->block_details[1]->content != '-1'){ $data['block_other']['question'][$val]['children']->limit($block->block_details[1]->content); } $data['block_other']['question'][$val]['children']->all(); } } }elseif($block->blocktype == 'block_comparison'){ //blocks新形式 //ComparisonSettings $comparison_setting_query = $this->Pages->find() ->select(['Pages.id', 'Pages.slug', 'Pages.other4', 'Pages.sort_flag', 'Pages.display_flag']) ->where(['Pages.pagetype_id' => 9]) ->where(['Pages.company_id' => $company_id]) ->where(['Pages.delete_flag' => 0]); //->first(); $data['block_other']['comparison_setting'][$block->id] = $comparison_setting_query->first(); // if($block->tmp_flag == 1){ if($block->other3 == 1){ $comparison_id_array = explode(',', $block->text1); foreach($comparison_id_array as $key=>$val){ $data['block_other']['comparison'][$val]['parent'] = $this->ComparisonCategories->find() ->where(['ComparisonCategories.id' => $val]) ->where(['ComparisonCategories.company_id' => $company_id]) ->where(['ComparisonCategories.delete_flag' => 0]) ->first(); $data['block_other']['comparison'][$val]['children'] = $this->Comparisons->find() ->where(['Comparisons.company_id' => $company_id]) ->where(['Comparisons.comparison_category_id' => $val]) ->where(['Comparisons.display_flag' => 1]) ->where(['Comparisons.delete_flag' => 0]); //->order(['Comparisons.sort' => 'ASC']); //昇順・降順 if($data['block_other']['comparison_setting'][$block->id]->sort_flag == 1){ $data['block_other']['comparison'][$val]['children']->order(['Comparisons.sort' => 'DESC']); }else{ $data['block_other']['comparison'][$val]['children']->order(['Comparisons.sort' => 'ASC']); } // if($block->other1 != '-1'){ $data['block_other']['comparison'][$val]['children']->limit($block->other1); } $data['block_other']['comparison'][$val]['children']->all(); } }elseif($block->other3 == 2){ $data['block_other']['comparison_bulk'][$block->id]['children'] = $this->Comparisons->find() ->where(['Comparisons.company_id' => $company_id]) ->where(['Comparisons.comparison_category_id IN' => explode(',', $block->text1)]) ->where(['Comparisons.display_flag' => 1]) ->where(['Comparisons.delete_flag' => 0]); //->order(['Comparisons.sort' => 'ASC']); //昇順・降順 if($data['block_other']['comparison_setting'][$block->id]->sort_flag == 1){ $data['block_other']['comparison_bulk'][$block->id]['children']->order(['Comparisons.sort' => 'DESC']); }else{ $data['block_other']['comparison_bulk'][$block->id]['children']->order(['Comparisons.sort' => 'ASC']); } // /*if($block->other1 != '-1'){ $data['block_other']['comparison'][$val]['children']->limit($block->other1); }*/ if($block->other1 != '-1'){ $data['block_other']['comparison_bulk'][$block->id]['children']->limit($block->other1); } $data['block_other']['comparison_bulk'][$block->id]['children']->all(); //1件表示 }else{ $data['block_other']['comparison_bulk'][$block->id]['children'] = $this->Comparisons->find() ->where(['Comparisons.id' => $block->text2]) ->where(['Comparisons.company_id' => $company_id]) ->where(['Comparisons.display_flag' => 1]) ->where(['Comparisons.delete_flag' => 0]) ->order(['Comparisons.sort' => 'ASC']) ->all(); } //blocks旧形式 }else{ if($block->block_details[0]->alt == 1){ $comparison_id_array = explode(',', $block->block_details[0]->content); foreach($comparison_id_array as $key=>$val){ $data['block_other']['comparison'][$val]['parent'] = $this->ComparisonCategories->find() ->where(['ComparisonCategories.id' => $val]) ->where(['ComparisonCategories.company_id' => $company_id]) ->where(['ComparisonCategories.delete_flag' => 0]) ->first(); $data['block_other']['comparison'][$val]['children'] = $this->Comparisons->find() ->where(['Comparisons.company_id' => $company_id]) ->where(['Comparisons.comparison_category_id' => $val]) ->where(['Comparisons.display_flag' => 1]) ->where(['Comparisons.delete_flag' => 0]) ->order(['Comparisons.sort' => 'ASC']); if($block->block_details[1]->content != '-1'){ $data['block_other']['comparison'][$val]['children']->limit($block->block_details[1]->content); } $data['block_other']['comparison'][$val]['children']->all(); } }else{ $data['block_other']['comparison_bulk'][$block->id]['children'] = $this->Comparisons->find() ->where(['Comparisons.company_id' => $company_id]) ->where(['Comparisons.comparison_category_id IN' => explode(',', $block->block_details[0]->content)]) ->where(['Comparisons.display_flag' => 1]) ->where(['Comparisons.delete_flag' => 0]) ->order(['Comparisons.sort' => 'ASC']); if($block->block_details[1]->content != '-1'){ $data['block_other']['comparison_bulk'][$block->id]['children']->limit($block->block_details[1]->content); } $data['block_other']['comparison_bulk'][$block->id]['children']->all(); } } }elseif($block->blocktype == 'block_form'){ //blocks新形式 if($block->tmp_flag == 1){ $data['block_other']['form'][$block->id]['parent'] = $this->Contacts->find() ->where(['Contacts.id' => $block->text1]) ->where(['Contacts.company_id' => $company_id]) ->where(['Contacts.delete_flag' => 0]) ->first(); $data['block_other']['form'][$block->id]['children'] = $this->ContactDetails->find() //->where(['ContactDetails.company_id' => $company_id]) ->where(['ContactDetails.contact_id' => $block->text1]) ->where(['ContactDetails.delete_flag' => 0]) ->order(['ContactDetails.sort' => 'ASC']) ->all(); $data['form_input_data'] = []; foreach($data['block_other']['form'][$block->id]['children'] as $child){ if($child->type == 'checkbox'){ $data['form_input_data'][$child->id] = []; }else{ $data['form_input_data'][$child->id] = ''; } } //blocks旧形式 }else{ $data['block_other']['form'][$block->block_details[0]->content]['parent'] = $this->Contacts->find() ->where(['Contacts.id' => $block->block_details[0]->content]) ->where(['Contacts.company_id' => $company_id]) ->where(['Contacts.delete_flag' => 0]) ->first(); $data['block_other']['form'][$block->block_details[0]->content]['children'] = $this->ContactDetails->find() //->where(['ContactDetails.company_id' => $company_id]) ->where(['ContactDetails.contact_id' => $block->block_details[0]->content]) ->where(['ContactDetails.delete_flag' => 0]) ->order(['ContactDetails.sort' => 'ASC']) ->all(); $data['form_input_data'] = []; foreach($data['block_other']['form'][$block->block_details[0]->content]['children'] as $child){ if($child->type == 'checkbox'){ $data['form_input_data'][$child->id] = []; }else{ $data['form_input_data'][$child->id] = ''; } } } }elseif($block->blocktype == 'block_link'){ //blocks新形式 if($block->tmp_flag == 1){ //無限ループ対策、同一サーバーのIPの場合はスキップ /*$tmp_ip = gethostbyname($block->text); if(!empty($tmp_ip) && $tmp_ip != '153.122.121.112'){ // if(!empty($block->text)){ $context = stream_context_create( [ 'http'=> [ 'ignore_errors'=>true ], 'ssl'=> [ 'verify_peer'=>false, 'verify_peer_name'=>false ] ] ); $tmp_html = @file_get_contents($block->text, false, $context); if(!empty($tmp_html)){ mb_language("Japanese"); $html = mb_convert_encoding($tmp_html, 'UTF-8', 'auto'); preg_match( "/(.*)<\/title>/i", $html, $matches); $data['block_other']['link'][$block->id]['name'] = $matches[1]; $meta = get_meta_tags($block->text); if(isset($meta['description']) && !empty($meta['description'])){ $data['block_other']['link'][$block->id]['description'] = mb_convert_encoding($meta['description'], 'UTF-8', 'auto'); }else{ $data['block_other']['link'][$block->id]['description'] = ''; } $data['block_other']['link'][$block->id]['url'] = $block->text; }else{ $data['block_other']['link'][$block->id]['url'] = $block->text; $data['block_other']['link'][$block->id]['name'] = ''; $data['block_other']['link'][$block->id]['description'] = ''; } }else{ //$data['block_other']['link'][$block->id] = []; $data['block_other']['link'][$block->id]['url'] = ''; $data['block_other']['link'][$block->id]['name'] = ''; $data['block_other']['link'][$block->id]['description'] = ''; } }*/ //blocks旧形式 }else{ //無限ループ対策、同一サーバーのIPの場合はスキップ $tmp_ip = gethostbyname($block->block_details[0]->content); if(!empty($tmp_ip) && $tmp_ip != '153.122.121.112'){ // if(!empty($block->block_details[0]->content)){ $context = stream_context_create( [ 'http'=> [ 'ignore_errors'=>true ], 'ssl'=> [ 'verify_peer'=>false, 'verify_peer_name'=>false ] ] ); $tmp_html = file_get_contents($block->block_details[0]->content, false, $context); if(!empty($tmp_html)){ mb_language("Japanese"); $html = mb_convert_encoding($tmp_html, 'UTF-8', 'auto'); preg_match( "/<title>(.*)<\/title>/i", $html, $matches); $data['block_other']['link'][$block->block_details[0]->id]['name'] = $matches[1]; $meta = get_meta_tags($block->block_details[0]->content); $data['block_other']['link'][$block->block_details[0]->id]['description'] = mb_convert_encoding($meta['description'], 'UTF-8', 'auto'); $data['block_other']['link'][$block->block_details[0]->id]['url'] = $block->block_details[0]->content; }else{ $data['block_other']['link'][$block->block_details[0]->id] = []; } }else{ $data['block_other']['link'][$block->block_details[0]->id] = []; } } } } } } return $data; } function basic_authenticate($name, $password, $realm = "Authentication"){ if(!isset($_SERVER['PHP_AUTH_USER']) || !($_SERVER['PHP_AUTH_USER'] == $name && $_SERVER['PHP_AUTH_PW'] == $password)){ header('WWW-Authenticate: Basic realm="'.$realm.'"'); header('HTTP/1.0 401 Unauthorized'); echo 'Not allowed to access.'; exit; } /*switch(true){ case !isset($_SERVER['PHP_AUTH_USER'], $_SERVER['PHP_AUTH_PW']): case $_SERVER['PHP_AUTH_USER'] !== $name: case $_SERVER['PHP_AUTH_PW'] !== $password: header('WWW-Authenticate: Basic realm="'.$realm.'"'); header('Content-Type: text/plain; charset=utf-8'); die('このページを見るにはログインが必要です'); }*/ } public function mystyleCss($navigation_id = null){ // if((strpos($_SERVER['HTTP_HOST'],'onerank-cms.com') !== false && $_SERVER['HTTP_HOST'] != 'onerank-cms.com') || (strpos($_SERVER['HTTP_HOST'],'onerank-cms-2.com') !== false && $_SERVER['HTTP_HOST'] != 'onerank-cms-2.com') || (strpos($_SERVER['HTTP_HOST'],'onerank-cms-3.com') !== false && $_SERVER['HTTP_HOST'] != 'onerank-cms-3.com') || (strpos($_SERVER['HTTP_HOST'],'onerank-hybrid-dev.com') !== false && $_SERVER['HTTP_HOST'] != 'onerank-hybrid-dev.com') || (strpos($_SERVER['HTTP_HOST'],'onerank-hybrid-dev2.com') !== false && $_SERVER['HTTP_HOST'] != 'onerank-hybrid-dev2.com') || (strpos($_SERVER['HTTP_HOST'],'onerank-hybrid-dev3.com') !== false && $_SERVER['HTTP_HOST'] != 'onerank-hybrid-dev3.com')){ $tmp_domain = SUB_DOMAIN; //顧客専用管理画面によるアクセスの場合 }else{ //$tmp_domain = $_SERVER['HTTP_HOST']; //wwwありなしの確認 if(substr($_SERVER['HTTP_HOST'], 0, 4) == 'www.'){ $tmp_domain = str_replace('www.', '', $_SERVER['HTTP_HOST']); }else{ $tmp_domain = $_SERVER['HTTP_HOST']; } } //Settingsのmystyle_cssと、Navigationsのmystyle_cssを、企業IDを軸に個別にcacheする。1_settings、1_navigations、の様に。 if(($data = Cache::read($tmp_domain, 'css')) === false){ //企業情報取得 $query = $this->Companies->find() ->where(['Companies.delete_flag' => 0]); //顧客用サブドメインによるアクセスの場合 if((strpos($_SERVER['HTTP_HOST'],'onerank-cms.com') !== false && $_SERVER['HTTP_HOST'] != 'onerank-cms.com') || (strpos($_SERVER['HTTP_HOST'],'onerank-cms-2.com') !== false && $_SERVER['HTTP_HOST'] != 'onerank-cms-2.com') || (strpos($_SERVER['HTTP_HOST'],'onerank-cms-3.com') !== false && $_SERVER['HTTP_HOST'] != 'onerank-cms-3.com') || (strpos($_SERVER['HTTP_HOST'],'onerank-hybrid-dev.com') !== false && $_SERVER['HTTP_HOST'] != 'onerank-hybrid-dev.com') || (strpos($_SERVER['HTTP_HOST'],'onerank-hybrid-dev2.com') !== false && $_SERVER['HTTP_HOST'] != 'onerank-hybrid-dev2.com') || (strpos($_SERVER['HTTP_HOST'],'onerank-hybrid-dev3.com') !== false && $_SERVER['HTTP_HOST'] != 'onerank-hybrid-dev3.com')){ $query->where(['Companies.subdomain' => SUB_DOMAIN]); //顧客専用管理画面によるアクセスの場合 }else{ //$query->where(['Companies.domain' => $_SERVER['HTTP_HOST']]); $query->where(['Companies.domain' => $tmp_domain]); } $company_data = $query->first(); // //$data['setting'] = $this->setting_data($company_data->id); if(isset($navigation_id) && !empty($navigation_id)){ $data['setting'] = $this->Navigations->find() ->select(['Navigations.mystyle_css']) ->where(['Navigations.id' => $navigation_id]) ->where(['Navigations.company_id' => $company_data->id]) ->where(['Navigations.delete_flag' => 0]) ->first(); if(empty($data['setting']->mystyle_css)){ $data['setting'] = $this->Settings->find() ->select(['Settings.mystyle_css']) ->where(['Settings.company_id' => $company_data->id]) ->where(['Settings.delete_flag' => 0]) ->first(); } }else{ $data['setting'] = $this->Settings->find() ->select(['Settings.mystyle_css']) ->where(['Settings.company_id' => $company_data->id]) ->where(['Settings.delete_flag' => 0]) ->first(); } //キャッシュの書き込み ※※※ //Cache::write($tmp_domain, $data, 'css'); } // $this->viewBuilder()->autoLayout(false); // //$this->response->type('text/css'); header('Content-Type: text/css; charaset=utf-8'); //データセット $this->set('data', $data); $this->response->charset('UTF-8'); $this->response->type('css'); } public function compressCss($mode = null, $value = null, $navigation_id = null){ // $css_file = [ 1 => 'index.css', 2 => 'cmn.css', 3 => 'gallery_archive.css', 4 => 'beforeafter_archive.css', 5 => 'news_archive.css', 6 => 'widget/contents_box01.css', 7 => 'widget/composite_box01.css', 8 => 'widget/widget_gallery01.css', 9 => 'widget/widget_staff01.css', 10 => 'widget/widget_news01.css', 11 => 'widget/widget_news02.css', 12 => 'widget/widget_menu01.css', 13 => 'widget/widget_map.css', 14 => 'widget/widget_lp01.css', 15 => 'widget/widget_lp02.css', 16 => 'widget/contents_box_slide01.css', 17 => 'widget/contents_table01.css', 18 => 'widget/contents_table02.css', 19 => 'widget/contents_table03.css', 20 => 'widget/contents_faq01.css', 21 => 'widget/contents_related.css', 22 => 'widget/contents_related_tags.css', 23 => 'widget/widget_shop01_list.css', 24 => 'widget/widget_shop01.css', 25 => 'widget/widget_youtube.css', 26 => 'widget/widget_coupon.css', 27 => 'widget/widget_tel.css', 28 => 'widget/widget_link.css', 29 => 'widget/widget_form.css', 30 => 'widget/widget_sitemap.css', 31 => 'gallery_single.css', 32 => 'recruit_archive.css', 33 => 'widget/widget_recruit.css', ]; //固定CSSのキャッシュ確認 if(($data = Cache::read($value, 'compress_css')) === false){ // $data = ''; $value_array = explode('.', $value); foreach($value_array as $key=>$val){ $tmp_data = ''; $tmp_data = file_get_contents('/var/www/html/application/webroot/'.$mode.'/css/'.$css_file[$val]); $data .= $tmp_data; } //キャッシュの書き込み ※※※ Cache::write($value, $data, 'compress_css'); } //圧縮処理 // コメント削除 $data = preg_replace('!/\*[^*]*\*+([^/][^*]*\*+)*/!', '', $data); // コロンの後の空白を削除する $data = str_replace(': ', ':', $data); // タブ、スペース、改行などを削除する $data = str_replace(array("\r\n", "\r", "\n", "\t", ' ', ' ', ' '), '', $data); // $this->viewBuilder()->autoLayout(false); // //$this->response->type('text/css'); header('Content-Type: text/css; charaset=utf-8'); //データセット $this->set('data', $data); $this->response->charset('UTF-8'); $this->response->type('css'); } public function _compressCss($mode = null, $value = null, $navigation_id = null){ // $css_file = [ 1 => 'index.css', 2 => 'cmn.css', 3 => 'gallery_archive.css', 4 => 'beforeafter_archive.css', 5 => 'news_archive.css', 6 => 'widget/contents_box01.css', 7 => 'widget/composite_box01.css', 8 => 'widget/widget_gallery01.css', 9 => 'widget/widget_staff01.css', 10 => 'widget/widget_news01.css', 11 => 'widget/widget_news02.css', 12 => 'widget/widget_menu01.css', 13 => 'widget/widget_map.css', 14 => 'widget/widget_lp01.css', 15 => 'widget/widget_lp02.css', 16 => 'widget/contents_box_slide01.css', 17 => 'widget/contents_table01.css', 18 => 'widget/contents_table02.css', 19 => 'widget/contents_table03.css', 20 => 'widget/contents_faq01.css', 21 => 'widget/contents_related.css', 22 => 'widget/contents_related_tags.css', 23 => 'widget/widget_shop01_list.css', 24 => 'widget/widget_shop01.css', 25 => 'widget/widget_youtube.css', 26 => 'widget/widget_coupon.css', 27 => 'widget/widget_tel.css', 28 => 'widget/widget_link.css', 29 => 'widget/widget_form.css', 30 => 'widget/widget_sitemap.css', 31 => 'gallery_single.css', 32 => 'recruit_archive.css', 33 => 'widget/widget_recruit.css', ]; //Settingsのmystyle_cssと、Navigationsのmystyle_cssを、企業IDを軸に個別にcacheする。1_settings、1_navigations、の様に。 if(($data = Cache::read($tmp_domain.'_'.$value, 'css')) === false){ //固定CSSのキャッシュ確認 if(($fixed_data = Cache::read($value, 'compress_css')) === false){ // $data = ''; $value_array = explode('.', $value); foreach($value_array as $key=>$val){ $tmp_data = ''; $tmp_data = file_get_contents('/var/www/html/application/webroot/'.$mode.'/css/'.$css_file[$val]); $data .= $tmp_data; } //キャッシュの書き込み ※※※ Cache::write($value, $fixed_data, 'compress_css'); } // if((strpos($_SERVER['HTTP_HOST'],'onerank-cms.com') !== false && $_SERVER['HTTP_HOST'] != 'onerank-cms.com') || (strpos($_SERVER['HTTP_HOST'],'onerank-cms-2.com') !== false && $_SERVER['HTTP_HOST'] != 'onerank-cms-2.com') || (strpos($_SERVER['HTTP_HOST'],'onerank-cms-3.com') !== false && $_SERVER['HTTP_HOST'] != 'onerank-cms-3.com') || (strpos($_SERVER['HTTP_HOST'],'onerank-hybrid-dev.com') !== false && $_SERVER['HTTP_HOST'] != 'onerank-hybrid-dev.com') || (strpos($_SERVER['HTTP_HOST'],'onerank-hybrid-dev2.com') !== false && $_SERVER['HTTP_HOST'] != 'onerank-hybrid-dev2.com') || (strpos($_SERVER['HTTP_HOST'],'onerank-hybrid-dev3.com') !== false && $_SERVER['HTTP_HOST'] != 'onerank-hybrid-dev3.com')){ $tmp_domain = SUB_DOMAIN; //顧客専用管理画面によるアクセスの場合 }else{ //$tmp_domain = $_SERVER['HTTP_HOST']; //wwwありなしの確認 if(substr($_SERVER['HTTP_HOST'], 0, 4) == 'www.'){ $tmp_domain = str_replace('www.', '', $_SERVER['HTTP_HOST']); }else{ $tmp_domain = $_SERVER['HTTP_HOST']; } } //企業情報取得 $query = $this->Companies->find() ->where(['Companies.delete_flag' => 0]); //顧客用サブドメインによるアクセスの場合 if((strpos($_SERVER['HTTP_HOST'],'onerank-cms.com') !== false && $_SERVER['HTTP_HOST'] != 'onerank-cms.com') || (strpos($_SERVER['HTTP_HOST'],'onerank-cms-2.com') !== false && $_SERVER['HTTP_HOST'] != 'onerank-cms-2.com') || (strpos($_SERVER['HTTP_HOST'],'onerank-cms-3.com') !== false && $_SERVER['HTTP_HOST'] != 'onerank-cms-3.com') || (strpos($_SERVER['HTTP_HOST'],'onerank-hybrid-dev.com') !== false && $_SERVER['HTTP_HOST'] != 'onerank-hybrid-dev.com') || (strpos($_SERVER['HTTP_HOST'],'onerank-hybrid-dev2.com') !== false && $_SERVER['HTTP_HOST'] != 'onerank-hybrid-dev2.com') || (strpos($_SERVER['HTTP_HOST'],'onerank-hybrid-dev3.com') !== false && $_SERVER['HTTP_HOST'] != 'onerank-hybrid-dev3.com')){ $query->where(['Companies.subdomain' => SUB_DOMAIN]); //顧客専用管理画面によるアクセスの場合 }else{ //$query->where(['Companies.domain' => $_SERVER['HTTP_HOST']]); $query->where(['Companies.domain' => $tmp_domain]); } $company_data = $query->first(); // //$data['setting'] = $this->setting_data($company_data->id); if(isset($navigation_id) && !empty($navigation_id)){ $setting = $this->Navigations->find() ->select(['Navigations.mystyle_css']) ->where(['Navigations.id' => $navigation_id]) ->where(['Navigations.company_id' => $company_data->id]) ->where(['Navigations.delete_flag' => 0]) ->first(); if(empty($setting->mystyle_css)){ $setting = $this->Settings->find() ->select(['Settings.mystyle_css']) ->where(['Settings.company_id' => $company_data->id]) ->where(['Settings.delete_flag' => 0]) ->first(); } }else{ $setting = $this->Settings->find() ->select(['Settings.mystyle_css']) ->where(['Settings.company_id' => $company_data->id]) ->where(['Settings.delete_flag' => 0]) ->first(); } $orijinal_data = $setting->mystyle_css; $data .= $orijinal_data; //圧縮処理 // コメント削除 $data = preg_replace('!/\*[^*]*\*+([^/][^*]*\*+)*/!', '', $data); // コロンの後の空白を削除する $data = str_replace(': ', ':', $data); // タブ、スペース、改行などを削除する $data = str_replace(array("\r\n", "\r", "\n", "\t", ' ', ' ', ' '), '', $data); //キャッシュの書き込み ※※※ Cache::write($tmp_domain.'_'.$value, $data, 'css'); } // $this->viewBuilder()->autoLayout(false); // //$this->response->type('text/css'); header('Content-Type: text/css; charaset=utf-8'); //データセット $this->set('data', $data); $this->response->charset('UTF-8'); $this->response->type('css'); } public function originalCss(){ //if(($data = Cache::read($_SERVER['HTTP_HOST'], 'company')) === false){ //企業情報取得 $query = $this->Companies->find() ->where(['Companies.delete_flag' => 0]); //顧客用サブドメインによるアクセスの場合 if((strpos($_SERVER['HTTP_HOST'],'onerank-cms.com') !== false && $_SERVER['HTTP_HOST'] != 'onerank-cms.com') || (strpos($_SERVER['HTTP_HOST'],'onerank-cms-2.com') !== false && $_SERVER['HTTP_HOST'] != 'onerank-cms-2.com') || (strpos($_SERVER['HTTP_HOST'],'onerank-cms-3.com') !== false && $_SERVER['HTTP_HOST'] != 'onerank-cms-3.com') || (strpos($_SERVER['HTTP_HOST'],'onerank-hybrid-dev.com') !== false && $_SERVER['HTTP_HOST'] != 'onerank-hybrid-dev.com') || (strpos($_SERVER['HTTP_HOST'],'onerank-hybrid-dev2.com') !== false && $_SERVER['HTTP_HOST'] != 'onerank-hybrid-dev2.com') || (strpos($_SERVER['HTTP_HOST'],'onerank-hybrid-dev3.com') !== false && $_SERVER['HTTP_HOST'] != 'onerank-hybrid-dev3.com')){ $query->where(['Companies.subdomain' => SUB_DOMAIN]); //顧客専用管理画面によるアクセスの場合 }else{ //$query->where(['Companies.domain' => $_SERVER['HTTP_HOST']]); //wwwありなしの確認 if(substr($_SERVER['HTTP_HOST'], 0, 4) == 'www.'){ $query->where(['Companies.domain' => str_replace('www.', '', $_SERVER['HTTP_HOST'])]); }else{ $query->where(['Companies.domain' => $_SERVER['HTTP_HOST']]); } } $company_data = $query->first(); //キャッシュの書き込み ※※※ //Cache::write($_SERVER['HTTP_HOST'], $company_data, 'company'); //} // if(isset($this->request->getParam('pass')[0]) && !empty($this->request->getParam('pass')[0]) && isset($this->request->getParam('pass')[1]) && !empty($this->request->getParam('pass')[1])){ $data['setting'] = $this->Newpages->find() ->select(['Newpages.css']) ->where(['Newpages.id' => $this->request->getParam('pass')[0]]) ->where(['Newpages.company_id' => $company_data->id]) ->where(['Newpages.display_flag' => 1]) ->where(['Newpages.delete_flag' => 0]) ->first(); /*}else{ //キャッシュの確認(セッティングデータ) $data['setting'] = $this->setting_data($company_data->id);*/ }elseif(isset($this->request->getParam('pass')[0]) && !empty($this->request->getParam('pass')[0])){ $data['setting'] = $this->Pages->find() ->select(['Pages.css']) ->where(['Pages.id' => $this->request->getParam('pass')[0]]) ->where(['Pages.company_id' => $company_data->id]) ->where(['Pages.display_flag' => 1]) ->where(['Pages.delete_flag' => 0]) ->first(); /*}else{ //キャッシュの確認(セッティングデータ) $data['setting'] = $this->setting_data($company_data->id);*/ } // $this->viewBuilder()->autoLayout(false); // $this->response->type('text/css'); //データセット $this->set('data', $data); } public function mystyleJs($navigation_id = null){ if((strpos($_SERVER['HTTP_HOST'],'onerank-cms.com') !== false && $_SERVER['HTTP_HOST'] != 'onerank-cms.com') || (strpos($_SERVER['HTTP_HOST'],'onerank-cms-2.com') !== false && $_SERVER['HTTP_HOST'] != 'onerank-cms-2.com') || (strpos($_SERVER['HTTP_HOST'],'onerank-cms-3.com') !== false && $_SERVER['HTTP_HOST'] != 'onerank-cms-3.com') || (strpos($_SERVER['HTTP_HOST'],'onerank-hybrid-dev.com') !== false && $_SERVER['HTTP_HOST'] != 'onerank-hybrid-dev.com') || (strpos($_SERVER['HTTP_HOST'],'onerank-hybrid-dev2.com') !== false && $_SERVER['HTTP_HOST'] != 'onerank-hybrid-dev2.com') || (strpos($_SERVER['HTTP_HOST'],'onerank-hybrid-dev3.com') !== false && $_SERVER['HTTP_HOST'] != 'onerank-hybrid-dev3.com')){ $tmp_domain = SUB_DOMAIN; //顧客専用管理画面によるアクセスの場合 }else{ //$tmp_domain = $_SERVER['HTTP_HOST']; //wwwありなしの確認 if(substr($_SERVER['HTTP_HOST'], 0, 4) == 'www.'){ $tmp_domain = str_replace('www.', '', $_SERVER['HTTP_HOST']); }else{ $tmp_domain = $_SERVER['HTTP_HOST']; } } //Settingsのmystyle_jsと、Navigationsのmystyle_jsを、企業IDを軸に個別にcacheする。1_settings、1_navigations、の様に。 if(($data = Cache::read($tmp_domain, 'js')) === false){ //企業情報取得 $query = $this->Companies->find() ->where(['Companies.delete_flag' => 0]); //顧客用サブドメインによるアクセスの場合 if((strpos($_SERVER['HTTP_HOST'],'onerank-cms.com') !== false && $_SERVER['HTTP_HOST'] != 'onerank-cms.com') || (strpos($_SERVER['HTTP_HOST'],'onerank-cms-2.com') !== false && $_SERVER['HTTP_HOST'] != 'onerank-cms-2.com') || (strpos($_SERVER['HTTP_HOST'],'onerank-cms-3.com') !== false && $_SERVER['HTTP_HOST'] != 'onerank-cms-3.com') || (strpos($_SERVER['HTTP_HOST'],'onerank-hybrid-dev.com') !== false && $_SERVER['HTTP_HOST'] != 'onerank-hybrid-dev.com') || (strpos($_SERVER['HTTP_HOST'],'onerank-hybrid-dev2.com') !== false && $_SERVER['HTTP_HOST'] != 'onerank-hybrid-dev2.com') || (strpos($_SERVER['HTTP_HOST'],'onerank-hybrid-dev3.com') !== false && $_SERVER['HTTP_HOST'] != 'onerank-hybrid-dev3.com')){ $query->where(['Companies.subdomain' => SUB_DOMAIN]); //顧客専用管理画面によるアクセスの場合 }else{ //$query->where(['Companies.domain' => $_SERVER['HTTP_HOST']]); $query->where(['Companies.domain' => $tmp_domain]); } $company_data = $query->first(); // //$data['setting'] = $this->setting_data($company_data->id); if(isset($navigation_id) && !empty($navigation_id)){ $data['setting'] = $this->Navigations->find() ->select(['Navigations.mystyle_js']) ->where(['Navigations.id' => $navigation_id]) ->where(['Navigations.company_id' => $company_data->id]) ->where(['Navigations.delete_flag' => 0]) ->first(); if(empty($data['setting']->mystyle_js)){ $data['setting'] = $this->Settings->find() ->select(['Settings.mystyle_js']) ->where(['Settings.company_id' => $company_data->id]) ->where(['Settings.delete_flag' => 0]) ->first(); } }else{ $data['setting'] = $this->Settings->find() ->select(['Settings.mystyle_js']) ->where(['Settings.company_id' => $company_data->id]) ->where(['Settings.delete_flag' => 0]) ->first(); } //キャッシュの書き込み ※※※ //Cache::write($tmp_domain, $data, 'js'); } // $this->viewBuilder()->autoLayout(false); // $this->response->type('application/x-javascript'); //データセット $this->set('data', $data); } public function originalJs(){ //if(($data = Cache::read($_SERVER['HTTP_HOST'], 'company')) === false){ //企業情報取得 $query = $this->Companies->find() ->where(['Companies.delete_flag' => 0]); //顧客用サブドメインによるアクセスの場合 if((strpos($_SERVER['HTTP_HOST'],'onerank-cms.com') !== false && $_SERVER['HTTP_HOST'] != 'onerank-cms.com') || (strpos($_SERVER['HTTP_HOST'],'onerank-cms-2.com') !== false && $_SERVER['HTTP_HOST'] != 'onerank-cms-2.com') || (strpos($_SERVER['HTTP_HOST'],'onerank-cms-3.com') !== false && $_SERVER['HTTP_HOST'] != 'onerank-cms-3.com') || (strpos($_SERVER['HTTP_HOST'],'onerank-hybrid-dev.com') !== false && $_SERVER['HTTP_HOST'] != 'onerank-hybrid-dev.com') || (strpos($_SERVER['HTTP_HOST'],'onerank-hybrid-dev2.com') !== false && $_SERVER['HTTP_HOST'] != 'onerank-hybrid-dev2.com') || (strpos($_SERVER['HTTP_HOST'],'onerank-hybrid-dev3.com') !== false && $_SERVER['HTTP_HOST'] != 'onerank-hybrid-dev3.com')){ $query->where(['Companies.subdomain' => SUB_DOMAIN]); //顧客専用管理画面によるアクセスの場合 }else{ //$query->where(['Companies.domain' => $_SERVER['HTTP_HOST']]); //wwwありなしの確認 if(substr($_SERVER['HTTP_HOST'], 0, 4) == 'www.'){ $query->where(['Companies.domain' => str_replace('www.', '', $_SERVER['HTTP_HOST'])]); }else{ $query->where(['Companies.domain' => $_SERVER['HTTP_HOST']]); } } $company_data = $query->first(); //キャッシュの書き込み ※※※ //Cache::write($_SERVER['HTTP_HOST'], $company_data, 'company'); //} // if(isset($this->request->getParam('pass')[0]) && !empty($this->request->getParam('pass')[0]) && isset($this->request->getParam('pass')[1]) && !empty($this->request->getParam('pass')[1])){ $data['setting'] = $this->Newpages->find() ->select(['Newpages.js']) ->where(['Newpages.id' => $this->request->getParam('pass')[0]]) ->where(['Newpages.company_id' => $company_data->id]) ->where(['Newpages.display_flag' => 1]) ->where(['Newpages.delete_flag' => 0]) ->first(); /*}else{ //キャッシュの確認(セッティングデータ) $data['setting'] = $this->setting_data($company_data->id);*/ }elseif(isset($this->request->getParam('pass')[0]) && !empty($this->request->getParam('pass')[0])){ $data['setting'] = $this->Pages->find() ->select(['Pages.js']) ->where(['Pages.id' => $this->request->getParam('pass')[0]]) ->where(['Pages.company_id' => $company_data->id]) ->where(['Pages.display_flag' => 1]) ->where(['Pages.delete_flag' => 0]) ->first(); /*}else{ //キャッシュの確認(セッティングデータ) $data['setting'] = $this->setting_data($company_data->id);*/ } // $this->viewBuilder()->autoLayout(false); // $this->response->type('application/x-javascript'); //データセット $this->set('data', $data); } function strtr_utf8(){ if (func_num_args() < 3) { list($str, $replace_pairs) = func_get_args(); //$this->log($replace_pairs, 'debug'); //既にアンカーが付いている部分を置き換え preg_match_all('/<a .*?>(.*?)<\/a>/', $str, $anker_matchs); $dictionary_j = 1; $anker_matchdatas = []; if(isset($anker_matchs[0]) && !empty($anker_matchs[0])){ foreach($anker_matchs[0] as $anker_matchkey=>$anker_matchvalue){ $anker_matchdatas['tmp_dictionary2_'.sprintf("%03d", $dictionary_j)] = $anker_matchvalue; $str = str_replace($anker_matchvalue, 'tmp_dictionary2_'.sprintf("%03d", $dictionary_j), $str); $dictionary_j++; } } $str = strtr($str, $replace_pairs); //既にアンカーが付いている部分を元に戻す if(!empty($anker_matchdatas)){ foreach($anker_matchdatas as $matchkey=>$matchvalue){ $str = str_replace($matchkey, $matchvalue, $str); } } // return $str; } else { list($str, $from, $to) = func_get_args(); //既にアンカーが付いている部分を置き換え preg_match_all('/<a .*?>(.*?)<\/a>/', $str, $anker_matchs); $dictionary_j = 1; $anker_matchdatas = []; if(isset($anker_matchs[0]) && !empty($anker_matchs[0])){ foreach($anker_matchs[0] as $anker_matchkey=>$anker_matchvalue){ $anker_matchdatas['tmp_dictionary2_'.sprintf("%03d", $dictionary_j)] = $anker_matchvalue; $str = str_replace($anker_matchvalue, 'tmp_dictionary2_'.sprintf("%03d", $dictionary_j), $str); $dictionary_j++; } } $from = preg_split('//u', $from, -1, PREG_SPLIT_NO_EMPTY); $to = preg_split('//u', $to, -1, PREG_SPLIT_NO_EMPTY); $replace_pairs = array(); foreach ($from as $i => $f) { if (!isset($to[$i])) { break; } $replace_pairs[$f] = $to[$i]; } //既にアンカーが付いている部分を元に戻す if(!empty($anker_matchdatas)){ foreach($anker_matchdatas as $matchkey=>$matchvalue){ $str = str_replace($matchkey, $matchvalue, $str); } } return strtr($str, $replace_pairs); } //return strtr($str, $replace_pairs); } public function request_uri_check($company_id, $slug, $fixed_slug, $request_uri, $page_num){ // if($fixed_slug == 'archive' || $fixed_slug == 'category' || $fixed_slug == 'tag' || $fixed_slug == 'form_conf' || $fixed_slug == 'form_send' || $fixed_slug == 'gallery_archive' || $fixed_slug == 'comparison_archive' || $fixed_slug == 'dictionary' || $fixed_slug == 'archive'){ return; } // $layer = ''; //slugからページデータの取得 $base_page = $this->Pages->find() ->select(['Pages.id', 'Pages.parent_id', 'Pages.pagetype_id']) //->contain(['Pagetypes']) ->where(['Pages.slug' => $slug]) ->where(['Pages.company_id' => $company_id]) ->where(['Pages.delete_flag' => 0]) ->first(); if(!empty($base_page)){ //記事データの場合 if($base_page->pagetype_id == 6){ $layer = '/detail/'.$slug.'/'; //新ギャラリー }elseif($base_page->pagetype_id == 8 && $fixed_slug == 'detail'){ return; //リクルート詳細 }elseif($base_page->pagetype_id == 10 && $fixed_slug == 'detail'){ return; }else{ $layer = '/'.$slug.'/'; } $parent_id = $base_page->parent_id; if($parent_id != NULL){ while($parent_id != 0){ //ページ情報取得 $tmp_page = $this->Pages->find() ->select(['Pages.id', 'Pages.parent_id', 'Pages.slug']) ->contain(['Pagetypes']) ->where(['Pages.id' => $parent_id]) ->where(['Pages.company_id' => $company_id]) //->where(['Frames.display_flag' => 1]) ->where(['Pages.delete_flag' => 0]) ->first(); if(!empty($tmp_page)){ $parent_id = $tmp_page->parent_id; $layer = '/'.$tmp_page->slug.$layer; } } } } // if(!empty($page_num)){ $layer = $layer.$page_num.'/'; } // if(!empty($layer) && $layer != '/' && $layer != '//' && $layer != $request_uri){ $this->redirect($layer, '301'); } } public function xml(){ // $this->autoRender = false; $this->viewBuilder()->autoLayout(false); $this->response->charset('UTF-8'); $this->response->type('text/xml'); // $xml_array = []; //企業情報取得 $query = $this->Companies->find() ->where(['Companies.delete_flag' => 0]); //顧客用サブドメインによるアクセスの場合 if((strpos($_SERVER['HTTP_HOST'],'onerank-cms.com') !== false && $_SERVER['HTTP_HOST'] != 'onerank-cms.com') || (strpos($_SERVER['HTTP_HOST'],'onerank-cms-2.com') !== false && $_SERVER['HTTP_HOST'] != 'onerank-cms-2.com') || (strpos($_SERVER['HTTP_HOST'],'onerank-cms-3.com') !== false && $_SERVER['HTTP_HOST'] != 'onerank-cms-3.com') || (strpos($_SERVER['HTTP_HOST'],'onerank-hybrid-dev.com') !== false && $_SERVER['HTTP_HOST'] != 'onerank-hybrid-dev.com') || (strpos($_SERVER['HTTP_HOST'],'onerank-hybrid-dev2.com') !== false && $_SERVER['HTTP_HOST'] != 'onerank-hybrid-dev2.com') || (strpos($_SERVER['HTTP_HOST'],'onerank-hybrid-dev3.com') !== false && $_SERVER['HTTP_HOST'] != 'onerank-hybrid-dev3.com')){ $query->where(['Companies.subdomain' => SUB_DOMAIN]); //顧客専用管理画面によるアクセスの場合 }else{ //$query->where(['Companies.domain' => $_SERVER['HTTP_HOST']]); //wwwありなしの確認 if(substr($_SERVER['HTTP_HOST'], 0, 4) == 'www.'){ $query->where(['Companies.domain' => str_replace('www.', '', $_SERVER['HTTP_HOST'])]); }else{ $query->where(['Companies.domain' => $_SERVER['HTTP_HOST']]); } } $company_data = $query->first(); // $setting = $this->Settings->find() ->where(['Settings.company_id' => $company_data->id]) ->where(['Settings.delete_flag' => 0]) ->first(); if(empty($setting->basic_account) || empty($setting->basic_password)){ // /*if(!empty($company_data->domain)){ $base_url = 'https://'.$company_data->domain.'/'; }else{ $base_url = 'https://'.$company_data->subdomain.'.onerank-cms.com/'; }*/ $base_url = 'https://'.$_SERVER['HTTP_HOST'].'/'; $base_url2 = 'https://'.$_SERVER['HTTP_HOST']; //全ページデータ取得 $pages_array = []; //if($company_data->cms_version == 1){ if($company_data->cms_version >= 1){ $pages_objects = $this->Newpages->find() ->select(['Newpages.id', 'Newpages.pagetype_id', 'Newpages.parent_id', 'Newpages.slug', 'Newpages.slug_plus', 'Newpages.release_date', 'Newpages.modified']) ->where(['Newpages.pagetype_id IN' => [1, 2, 3, 4, 5, 6, 8, 9, 10, 12, 13, 14]]) ->where(['Newpages.company_id' => $company_data->id]) ->where(['Newpages.display_flag' => 1]) ->where(['Newpages.delete_flag' => 0]) ->order(['Newpages.sort' => 'ASC']); }else{ $pages_objects = $this->Pages->find() ->select(['Pages.id', 'Pages.pagetype_id', 'Pages.parent_id', 'Pages.slug', 'Pages.slug_plus', 'Pages.release_date', 'Pages.modified']) ->where(['Pages.pagetype_id IN' => [1, 2, 3, 4, 5, 6, 8, 9, 10, 12, 13, 14]]) ->where(['Pages.company_id' => $company_data->id]) ->where(['Pages.display_flag' => 1]) ->where(['Pages.delete_flag' => 0]) ->order(['Pages.sort' => 'ASC']); } // $recruit_id = ''; $recruit_slug = ''; foreach($pages_objects as $pages_object){ $tmp_page = []; $tmp_page['id'] = $pages_object->id; $tmp_page['pagetype_id'] = $pages_object->pagetype_id; $tmp_page['parent_id'] = $pages_object->parent_id; $tmp_page['slug'] = $pages_object->slug; if(!empty($pages_object->release_date)){ $tmp_page['release_date'] = $pages_object->release_date->format('Y-m-d H:i:s'); }else{ $tmp_page['release_date'] = ''; } $tmp_page['modified'] = $pages_object->modified->i18nFormat('YYYY-MM-dd HH:mm:ss'); $tmp_page['modified'] = str_replace(' ', 'T', $tmp_page['modified']).'+09:00'; $pages_array[] = $tmp_page; if($pages_object->pagetype_id == 10){ $recruit_id = $pages_object->id; $recruit_slug = $pages_object->slug_plus; } } foreach($pages_array as $page){ $tmp_xml_array = []; if($page['pagetype_id'] == 1){ $tmp_xml_array['url'] = $base_url; $tmp_xml_array['lastmod'] = $page['modified']; $xml_array[] = $tmp_xml_array; }elseif($page['parent_id'] == 0){ if(!empty($page['slug']) && !empty($page['modified'])){ $tmp_xml_array['url'] = $base_url.$page['slug'].'/'; $tmp_xml_array['lastmod'] = $page['modified']; $xml_array[] = $tmp_xml_array; } //カテゴリ if($page['pagetype_id'] == 2 || $page['pagetype_id'] == 3 || $page['pagetype_id'] == 5 || $page['pagetype_id'] == 12){ $category_datas = $this->xml_categories($company_data->id, $page['pagetype_id'], $page['id'], $base_url.$page['slug'].'/'); if(!empty($category_datas)){ foreach($category_datas as $category_data){ if(!empty($category_data['url']) && !empty($category_data['lastmod'])){ $tmp_xml_array['url'] = $category_data['url']; $tmp_xml_array['lastmod'] = $category_data['lastmod']; $xml_array[] = $tmp_xml_array; } } } } // foreach($pages_array as $page2){ if($page2['parent_id'] == $page['id'] && $page2['pagetype_id'] != 6){ if(!empty($page2['slug']) && !empty($page2['modified'])){ $tmp_xml_array['url'] = $base_url.$page['slug'].'/'.$page2['slug'].'/'; $tmp_xml_array['lastmod'] = $page2['modified']; $xml_array[] = $tmp_xml_array; } //カテゴリ if($page['pagetype_id'] == 2 || $page['pagetype_id'] == 3 || $page['pagetype_id'] == 5 || $page['pagetype_id'] == 12){ $category_datas = $this->xml_categories($company_data->id, $page['pagetype_id'], $page['id'], $base_url.$page['slug'].'/'.$page2['slug'].'/'); if(!empty($category_datas)){ foreach($category_datas as $category_data){ if(!empty($category_datas['url']) && !empty($category_datas['lastmod'])){ $tmp_xml_array['url'] = $category_datas['url']; $tmp_xml_array['lastmod'] = $category_datas['lastmod']; $xml_array[] = $tmp_xml_array; } } } } // foreach($pages_array as $page3){ if($page3['parent_id'] == $page2['id'] && $page2['pagetype_id'] != 6){ if(!empty($page3['slug']) && !empty($page3['modified'])){ $tmp_xml_array['url'] = $base_url.$page['slug'].'/'.$page2['slug'].'/'.$page3['slug'].'/'; $tmp_xml_array['lastmod'] = $page3['modified']; $xml_array[] = $tmp_xml_array; } //カテゴリ if($page['pagetype_id'] == 2 || $page['pagetype_id'] == 3 || $page['pagetype_id'] == 5 || $page['pagetype_id'] == 12){ $category_datas = $this->xml_categories($company_data->id, $page['pagetype_id'], $page['id'], $base_url.$page['slug'].'/'.$page2['slug'].'/'.$page3['slug'].'/'); if(!empty($category_datas)){ foreach($category_datas as $category_data){ if(!empty($category_datas['url']) && !empty($category_datas['lastmod'])){ $tmp_xml_array['url'] = $category_datas['url']; $tmp_xml_array['lastmod'] = $category_datas['lastmod']; $xml_array[] = $tmp_xml_array; } } } } }elseif($page3['parent_id'] == $page2['id'] && $page2['pagetype_id'] == 6){ if(!empty($page3['slug']) && !empty($page3['modified'])){ $tmp_xml_array['url'] = $base_url.$page['slug'].'/'.$page2['slug'].'/detail/'.$page3['slug'].'/'; $tmp_xml_array['lastmod'] = $page3['modified']; $xml_array[] = $tmp_xml_array; } } } }elseif($page2['parent_id'] == $page['id'] && $page2['pagetype_id'] == 6){ if($page2['release_date'] < date('Y-m-d H:i:s')){ if(!empty($page2['slug']) && !empty($page2['modified'])){ $tmp_xml_array['url'] = $base_url.$page['slug'].'/detail/'.$page2['slug'].'/'; $tmp_xml_array['lastmod'] = $page2['modified']; $xml_array[] = $tmp_xml_array; } } } } } } //リクルート if($recruit_id != '' && $recruit_slug != ''){ $recruits = $this->Recruits->find() ->where(['Recruits.company_id' => $company_data->id]) ->where(['Recruits.display_flag' => 1]) ->where(['Recruits.delete_flag' => 0]) //->order(['Recruits.created' => 'DESC']); ->order(['Recruits.sort' => 'ASC']); } if(!empty($recruits)){ foreach($recruits as $recruit){ $tmp_xml_array['url'] = $base_url2.$recruit_slug.'detail/'.$recruit->id.'/'; //$tmp_xml_array['lastmod'] = $recruit->modified->i18nFormat('YYYY-MM-dd'); $tmp_xml_array['lastmod'] = $recruit->modified->i18nFormat('YYYY-MM-dd HH:mm:ss'); $tmp_xml_array['lastmod'] = str_replace(' ', 'T', $tmp_xml_array['lastmod']).'+09:00'; $xml_array[] = $tmp_xml_array; } } //タグ $tags = $this->Tags->find() ->where(['Tags.company_id' => $company_data->id]) ->where(['OR' => [['Tags.content IS NOT' => ''], ['Tags.content2 IS NOT' => '']]]) ->all(); if(!empty($tags)){ foreach($tags as $tag){ $tmp_xml_array['url'] = $base_url.'page/tag/'.urlencode($tag->name).'/'; //$tmp_xml_array['lastmod'] = $tag->modified->format('Y-m-d H:i:s'); $tmp_xml_array['lastmod'] = $tag->modified->i18nFormat('YYYY-MM-dd HH:mm:ss'); $tmp_xml_array['lastmod'] = str_replace(' ', 'T', $tmp_xml_array['lastmod']).'+09:00'; $xml_array[] = $tmp_xml_array; } } /*echo "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"; echo "<urlset xmlns=\"http://www.sitemaps.org/schemas/sitemap/0.9\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\">\n"; foreach($xml_array as $row){ echo "<url>\n"; echo " <loc>".$row['url']."</loc>\n"; echo " <lastmod>".$row['lastmod']."</lastmod>\n"; echo "</url>\n"; } echo "</urlset>\n";*/ $response_data = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"; $response_data .= "<urlset xmlns=\"http://www.sitemaps.org/schemas/sitemap/0.9\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\">\n"; foreach($xml_array as $row){ $response_data .= "<url>\n"; $response_data .= " <loc>".htmlspecialchars($row['url'])."</loc>\n"; $response_data .= " <lastmod>".$row['lastmod']."</lastmod>\n"; $response_data .= "</url>\n"; } $response_data .= "</urlset>\n"; }else{ $response_data = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"; $response_data .= "<urlset xmlns=\"http://www.sitemaps.org/schemas/sitemap/0.9\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\">\n"; $response_data .= "</urlset>\n"; } $this->response->body($response_data); } public function llms(){ // $this->autoRender = false; $this->viewBuilder()->autoLayout(false); $this->response->charset('UTF-8'); //$this->response->type('text/xml'); // $response_data = '# Title'; $this->response->body($response_data); } public function urlList(){ // $this->autoRender = false; $this->viewBuilder()->autoLayout(false); $this->response->charset('UTF-8'); // $xml_array = []; //企業情報取得 $query = $this->Companies->find() ->where(['Companies.delete_flag' => 0]); //顧客用サブドメインによるアクセスの場合 if((strpos($_SERVER['HTTP_HOST'],'onerank-cms.com') !== false && $_SERVER['HTTP_HOST'] != 'onerank-cms.com') || (strpos($_SERVER['HTTP_HOST'],'onerank-cms-2.com') !== false && $_SERVER['HTTP_HOST'] != 'onerank-cms-2.com') || (strpos($_SERVER['HTTP_HOST'],'onerank-cms-3.com') !== false && $_SERVER['HTTP_HOST'] != 'onerank-cms-3.com') || (strpos($_SERVER['HTTP_HOST'],'onerank-hybrid-dev.com') !== false && $_SERVER['HTTP_HOST'] != 'onerank-hybrid-dev.com') || (strpos($_SERVER['HTTP_HOST'],'onerank-hybrid-dev2.com') !== false && $_SERVER['HTTP_HOST'] != 'onerank-hybrid-dev2.com') || (strpos($_SERVER['HTTP_HOST'],'onerank-hybrid-dev3.com') !== false && $_SERVER['HTTP_HOST'] != 'onerank-hybrid-dev3.com')){ $query->where(['Companies.subdomain' => SUB_DOMAIN]); //顧客専用管理画面によるアクセスの場合 }else{ //$query->where(['Companies.domain' => $_SERVER['HTTP_HOST']]); //wwwありなしの確認 if(substr($_SERVER['HTTP_HOST'], 0, 4) == 'www.'){ $query->where(['Companies.domain' => str_replace('www.', '', $_SERVER['HTTP_HOST'])]); }else{ $query->where(['Companies.domain' => $_SERVER['HTTP_HOST']]); } } $company_data = $query->first(); // $setting = $this->Settings->find() ->where(['Settings.company_id' => $company_data->id]) ->where(['Settings.delete_flag' => 0]) ->first(); $base_url = 'https://'.$_SERVER['HTTP_HOST'].'/'; $base_url2 = 'https://'.$_SERVER['HTTP_HOST']; //全ページデータ取得 $pages_array = []; //if($company_data->cms_version == 1){ if($company_data->cms_version >= 1){ $pages_objects = $this->Newpages->find() ->select(['Newpages.id', 'Newpages.pagetype_id', 'Newpages.parent_id', 'Newpages.slug', 'Newpages.slug_plus', 'Newpages.release_date', 'Newpages.modified']) ->where(['Newpages.pagetype_id IN' => [1, 2, 3, 4, 5, 6, 8, 9, 10, 12, 13, 14]]) ->where(['Newpages.company_id' => $company_data->id]) ->where(['Newpages.display_flag' => 1]) ->where(['Newpages.delete_flag' => 0]) ->order(['Newpages.sort' => 'ASC']); }else{ $pages_objects = $this->Pages->find() ->select(['Pages.id', 'Pages.pagetype_id', 'Pages.parent_id', 'Pages.slug', 'Pages.slug_plus', 'Pages.release_date', 'Pages.modified']) ->where(['Pages.pagetype_id IN' => [1, 2, 3, 4, 5, 6, 8, 9, 10, 12, 13, 14]]) ->where(['Pages.company_id' => $company_data->id]) ->where(['Pages.display_flag' => 1]) ->where(['Pages.delete_flag' => 0]) ->order(['Pages.sort' => 'ASC']); } // $recruit_id = ''; $recruit_slug = ''; foreach($pages_objects as $pages_object){ $tmp_page = []; $tmp_page['id'] = $pages_object->id; $tmp_page['pagetype_id'] = $pages_object->pagetype_id; $tmp_page['parent_id'] = $pages_object->parent_id; $tmp_page['slug'] = $pages_object->slug; if(!empty($pages_object->release_date)){ $tmp_page['release_date'] = $pages_object->release_date->format('Y-m-d H:i:s'); }else{ $tmp_page['release_date'] = ''; } $tmp_page['modified'] = $pages_object->modified->i18nFormat('YYYY-MM-dd HH:mm:ss'); $tmp_page['modified'] = str_replace(' ', 'T', $tmp_page['modified']).'+09:00'; $pages_array[] = $tmp_page; if($pages_object->pagetype_id == 10){ $recruit_id = $pages_object->id; $recruit_slug = $pages_object->slug_plus; } } foreach($pages_array as $page){ $tmp_xml_array = []; if($page['pagetype_id'] == 1){ $tmp_xml_array['url'] = $base_url; $tmp_xml_array['lastmod'] = $page['modified']; $xml_array[] = $tmp_xml_array; }elseif($page['parent_id'] == 0){ if(!empty($page['slug']) && !empty($page['modified'])){ $tmp_xml_array['url'] = $base_url.$page['slug'].'/'; $tmp_xml_array['lastmod'] = $page['modified']; $xml_array[] = $tmp_xml_array; } // foreach($pages_array as $page2){ if($page2['parent_id'] == $page['id'] && $page2['pagetype_id'] != 6){ if(!empty($page2['slug']) && !empty($page2['modified'])){ $tmp_xml_array['url'] = $base_url.$page['slug'].'/'.$page2['slug'].'/'; $tmp_xml_array['lastmod'] = $page2['modified']; $xml_array[] = $tmp_xml_array; } // foreach($pages_array as $page3){ if($page3['parent_id'] == $page2['id'] && $page2['pagetype_id'] != 6){ if(!empty($page3['slug']) && !empty($page3['modified'])){ $tmp_xml_array['url'] = $base_url.$page['slug'].'/'.$page2['slug'].'/'.$page3['slug'].'/'; $tmp_xml_array['lastmod'] = $page3['modified']; $xml_array[] = $tmp_xml_array; } } } } } } } /*$response_data = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"; $response_data .= "<urlset xmlns=\"http://www.sitemaps.org/schemas/sitemap/0.9\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\">\n"; foreach($xml_array as $row){ $response_data .= "<url>\n"; $response_data .= " <loc>".$row['url']."</loc>\n"; $response_data .= " <lastmod>".$row['lastmod']."</lastmod>\n"; $response_data .= "</url>\n"; } $response_data .= "</urlset>\n"; $this->response->body($response_data);*/ $i = 0; foreach($xml_array as $row){ echo $row['url'].'<br>'; if($i == 4){ echo '<br>'; $i = 0; }else{ $i++; } } echo $base_url.'sitemap/'; } public function xml_categories($company_id = null, $pagetype_id = null, $page_id = null, $url = null){ //ブログカテゴリ if($pagetype_id == 2){ $category_datas = $this->BlogCategories->find() ->where(['BlogCategories.company_id' => $company_id]) ->where(['BlogCategories.blog_id' => $page_id]) ->where(['OR' => [['BlogCategories.content IS NOT' => ''], ['BlogCategories.content2 IS NOT' => '']]]) ->all(); }elseif($pagetype_id == 3){ $category_datas = $this->NewsCategories->find() ->where(['NewsCategories.company_id' => $company_id]) ->where(['NewsCategories.news_id' => $page_id]) ->where(['OR' => [['NewsCategories.content IS NOT' => ''], ['NewsCategories.content2 IS NOT' => '']]]) ->all(); }elseif($pagetype_id == 5){ $category_datas = $this->ColumnCategories->find() ->where(['ColumnCategories.company_id' => $company_id]) ->where(['ColumnCategories.column_id' => $page_id]) ->where(['OR' => [['ColumnCategories.content IS NOT' => ''], ['ColumnCategories.content2 IS NOT' => '']]]) ->all(); }elseif($pagetype_id == 12){ $category_datas = $this->MultigalleryCategories->find() ->where(['MultigalleryCategories.company_id' => $company_id]) ->where(['MultigalleryCategories.multigallery_id' => $page_id]) ->where(['OR' => [['MultigalleryCategories.content IS NOT' => ''], ['MultigalleryCategories.content2 IS NOT' => '']]]) ->all(); } $return_datas = []; if(!empty($category_datas)){ foreach($category_datas as $category_data){ $tmp_return_datas = []; $tmp_return_datas['url'] = $url.'category/'.urlencode($category_data->name).'/'; //$tmp_return_datas['lastmod'] = $category_data->modified->format('Y-m-d H:i:s'); $tmp_return_datas['lastmod'] = $category_data->modified->i18nFormat('yyyy-MM-dd HH:mm:ss'); $tmp_return_datas['lastmod'] = str_replace(' ', 'T', $tmp_return_datas['lastmod']).'+09:00'; $return_datas[] = $tmp_return_datas; } } return $return_datas; } public function rss($id = null){ // $this->autoRender = false; $this->viewBuilder()->autoLayout(false); $this->response->charset('UTF-8'); $this->response->type('text/xml'); // $xml_array = []; //企業情報取得 $query = $this->Companies->find() ->where(['Companies.delete_flag' => 0]); //顧客用サブドメインによるアクセスの場合 if((strpos($_SERVER['HTTP_HOST'],'onerank-cms.com') !== false && $_SERVER['HTTP_HOST'] != 'onerank-cms.com') || (strpos($_SERVER['HTTP_HOST'],'onerank-cms-2.com') !== false && $_SERVER['HTTP_HOST'] != 'onerank-cms-2.com') || (strpos($_SERVER['HTTP_HOST'],'onerank-cms-3.com') !== false && $_SERVER['HTTP_HOST'] != 'onerank-cms-3.com') || (strpos($_SERVER['HTTP_HOST'],'onerank-hybrid-dev.com') !== false && $_SERVER['HTTP_HOST'] != 'onerank-hybrid-dev.com') || (strpos($_SERVER['HTTP_HOST'],'onerank-hybrid-dev2.com') !== false && $_SERVER['HTTP_HOST'] != 'onerank-hybrid-dev2.com') || (strpos($_SERVER['HTTP_HOST'],'onerank-hybrid-dev3.com') !== false && $_SERVER['HTTP_HOST'] != 'onerank-hybrid-dev3.com')){ $query->where(['Companies.subdomain' => SUB_DOMAIN]); //顧客専用管理画面によるアクセスの場合 }else{ //$query->where(['Companies.domain' => $_SERVER['HTTP_HOST']]); //wwwありなしの確認 if(substr($_SERVER['HTTP_HOST'], 0, 4) == 'www.'){ $query->where(['Companies.domain' => str_replace('www.', '', $_SERVER['HTTP_HOST'])]); }else{ $query->where(['Companies.domain' => $_SERVER['HTTP_HOST']]); } } $company_data = $query->first(); //親ページ if($company_data->cms_version >= 1){ $parent_data = $this->Newpages->find() ->select(['Newpages.id', 'Newpages.pagetype_id', 'Newpages.parent_id', 'Newpages.title', 'Newpages.description', 'Newpages.slug', 'Newpages.slug_plus', 'Newpages.release_date', 'Newpages.modified']) ->where(['Newpages.id' => $id]) ->where(['Newpages.company_id' => $company_data->id]) ->where(['Newpages.display_flag' => 1]) ->where(['Newpages.delete_flag' => 0]) ->first(); }else{ $parent_data = $this->Pages->find() ->select(['Pages.id', 'Pages.pagetype_id', 'Pages.parent_id', 'Pages.title', 'Pages.description', 'Pages.slug', 'Pages.slug_plus', 'Pages.release_date', 'Pages.modified']) ->where(['Pages.id' => $id]) ->where(['Pages.company_id' => $company_data->id]) ->where(['Pages.display_flag' => 1]) ->where(['Pages.delete_flag' => 0]) ->first(); } if($parent_data->parent_id != 0){ if($company_data->cms_version >= 1){ $parent_data2 = $this->Newpages->find() ->select(['Newpages.id', 'Newpages.pagetype_id', 'Newpages.parent_id', 'Newpages.slug', 'Newpages.slug_plus', 'Newpages.release_date', 'Newpages.modified']) ->where(['Newpages.id' => $parent_data->parent_id]) ->where(['Newpages.company_id' => $company_data->id]) ->where(['Newpages.display_flag' => 1]) ->where(['Newpages.delete_flag' => 0]) ->first(); }else{ $parent_data2 = $this->Pages->find() ->select(['Pages.id', 'Pages.pagetype_id', 'Pages.parent_id', 'Pages.slug', 'Pages.slug_plus', 'Pages.release_date', 'Pages.modified']) ->where(['Pages.id' => $parent_data->parent_id]) ->where(['Pages.company_id' => $company_data->id]) ->where(['Pages.display_flag' => 1]) ->where(['Pages.delete_flag' => 0]) ->first(); } if($parent_data2->parent_id != 0){ if($company_data->cms_version >= 1){ $parent_data3 = $this->Newpages->find() ->select(['Newpages.id', 'Newpages.pagetype_id', 'Newpages.parent_id', 'Newpages.slug', 'Newpages.slug_plus', 'Newpages.release_date', 'Newpages.modified']) ->where(['Newpages.id' => $parent_data->parent_id]) ->where(['Newpages.company_id' => $company_data->id]) ->where(['Newpages.display_flag' => 1]) ->where(['Newpages.delete_flag' => 0]) ->first(); }else{ $parent_data3 = $this->Pages->find() ->select(['Pages.id', 'Pages.pagetype_id', 'Pages.parent_id', 'Pages.slug', 'Pages.slug_plus', 'Pages.release_date', 'Pages.modified']) ->where(['Pages.id' => $parent_data->parent_id]) ->where(['Pages.company_id' => $company_data->id]) ->where(['Pages.display_flag' => 1]) ->where(['Pages.delete_flag' => 0]) ->first(); } $base_url = 'https://'.$_SERVER['HTTP_HOST'].'/'.$parent_data2->slug.'/'.$parent_data2->slug.'/'.$parent_data->slug.'/'; $base_url2 = 'https://'.$_SERVER['HTTP_HOST'].'/'.$parent_data2->slug.'/'.$parent_data2->slug.'/'.$parent_data->slug.'/detail/'; }else{ $base_url = 'https://'.$_SERVER['HTTP_HOST'].'/'.$parent_data2->slug.'/'.$parent_data->slug.'/'; $base_url2 = 'https://'.$_SERVER['HTTP_HOST'].'/'.$parent_data2->slug.'/'.$parent_data->slug.'/detail/'; } }else{ $base_url = 'https://'.$_SERVER['HTTP_HOST'].'/'.$parent_data->slug.'/'; $base_url2 = 'https://'.$_SERVER['HTTP_HOST'].'/'.$parent_data->slug.'/detail/'; } //子ページデータ取得 $pages_array = []; //if($company_data->cms_version == 1){ if($company_data->cms_version >= 1){ $pages_objects = $this->Newpages->find() ->select(['Newpages.id', 'Newpages.pagetype_id', 'Newpages.parent_id', 'Newpages.title', 'Newpages.description', 'Newpages.ameblo_content', 'Newpages.slug', 'Newpages.slug_plus', 'Newpages.release_date', 'Newpages.modified']) ->where(['Newpages.pagetype_id IN' => 6]) ->where(['Newpages.company_id' => $company_data->id]) ->where(['Newpages.parent_id' => $id]) ->where(['Newpages.release_date <=' => date('Y-m-d H:i:s')]) ->where(['Newpages.display_flag' => 1]) ->where(['Newpages.delete_flag' => 0]) //->order(['Newpages.release_date' => 'DESC']) ->order(['Newpages.release_date' => 'DESC', 'Newpages.id' => 'DESC']) ->limit(10); }else{ $pages_objects = $this->Pages->find() ->select(['Pages.id', 'Pages.pagetype_id', 'Pages.parent_id', 'Pages.title', 'Pages.description', 'Pages.ameblo_content', 'Pages.slug', 'Pages.slug_plus', 'Pages.release_date', 'Pages.modified']) ->where(['Pages.pagetype_id IN' => 6]) ->where(['Pages.company_id' => $company_data->id]) ->where(['Pages.parent_id' => $id]) ->where(['Pages.release_date <=' => date('Y-m-d H:i:s')]) ->where(['Pages.display_flag' => 1]) ->where(['Pages.delete_flag' => 0]) ->order(['Pages.release_date' => 'DESC']) ->limit(10); } /*$response_data = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"; $response_data .= "<urlset xmlns=\"http://www.sitemaps.org/schemas/sitemap/0.9\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\">\n";*/ $response_data = "<?xml version=\"1.0\" encoding=\"utf-8\" ?>\n"; $response_data .= "<rss version=\"2.0\" xmlns:atom=\"http://www.w3.org/2005/Atom\">\n"; $response_data .= "<channel>\n"; $response_data .= "<title>".strip_tags($parent_data->title, '<br>')."\n"; $response_data .= "".$base_url."\n"; $response_data .= "id."/\" rel=\"self\" type=\"application/rss+xml\" />\n"; $response_data .= "".$parent_data->description."\n"; $response_data .= "ja\n"; // foreach($pages_objects as $pages_object){ /*$tmp_page = []; $tmp_page['id'] = $pages_object->id; $tmp_page['pagetype_id'] = $pages_object->pagetype_id; $tmp_page['parent_id'] = $pages_object->parent_id; $tmp_page['slug'] = $pages_object->slug; if(!empty($pages_object->release_date)){ $tmp_page['release_date'] = $pages_object->release_date->format('Y-m-d H:i:s'); }else{ $tmp_page['release_date'] = ''; } $tmp_page['modified'] = $pages_object->modified->i18nFormat('YYYY-MM-dd'); $pages_array[] = $tmp_page; if($pages_object->pagetype_id == 10){ $recruit_id = $pages_object->id; $recruit_slug = $pages_object->slug_plus; }*/ $response_data .= "\n"; $response_data .= "".strip_tags($pages_object->title)."\n"; $response_data .= "\n"; $response_data .= "description)){ $response_data .= "".$pages_object->description."\n"; }else{ $response_data .= "".$pages_object->ameblo_content."\n"; } $response_data .= "]]>\n"; $response_data .= "\n"; $response_data .= "".$base_url2.$pages_object->slug."/\n"; date_default_timezone_set('Asia/Tokyo'); $pubDate = ''; $pubDate = date("D, d M Y H:i:s", strtotime($pages_object->release_date)); $response_data .= "".$pubDate." +0900\n"; $response_data .= "\n"; } $response_data .= "\n"; $response_data .= "\n"; // $this->response->body($response_data); } public function websub($id = null){ // $this->autoRender = false; $this->viewBuilder()->autoLayout(false); $this->response->charset('UTF-8'); $this->response->type('text/xml'); // $xml_array = []; //顧客用サブドメインによるアクセスの場合、生成しない if((strpos($_SERVER['HTTP_HOST'],'onerank-cms.com') !== false && $_SERVER['HTTP_HOST'] != 'onerank-cms.com') || (strpos($_SERVER['HTTP_HOST'],'onerank-cms-2.com') !== false && $_SERVER['HTTP_HOST'] != 'onerank-cms-2.com') || (strpos($_SERVER['HTTP_HOST'],'onerank-cms-3.com') !== false && $_SERVER['HTTP_HOST'] != 'onerank-cms-3.com') || (strpos($_SERVER['HTTP_HOST'],'onerank-hybrid-dev.com') !== false && $_SERVER['HTTP_HOST'] != 'onerank-hybrid-dev.com') || (strpos($_SERVER['HTTP_HOST'],'onerank-hybrid-dev2.com') !== false && $_SERVER['HTTP_HOST'] != 'onerank-hybrid-dev2.com') || (strpos($_SERVER['HTTP_HOST'],'onerank-hybrid-dev3.com') !== false && $_SERVER['HTTP_HOST'] != 'onerank-hybrid-dev3.com')){ }else{ //企業情報取得 $query = $this->Companies->find() ->where(['Companies.delete_flag' => 0]); //$query->where(['Companies.domain' => $_SERVER['HTTP_HOST']]); //wwwありなしの確認 if(substr($_SERVER['HTTP_HOST'], 0, 4) == 'www.'){ $query->where(['Companies.domain' => str_replace('www.', '', $_SERVER['HTTP_HOST'])]); }else{ $query->where(['Companies.domain' => $_SERVER['HTTP_HOST']]); } $company_data = $query->first(); //ページ if($company_data->cms_version >= 1){ $page_data = $this->Newpages->find() ->select(['Newpages.id', 'Newpages.pagetype_id', 'Newpages.parent_id', 'Newpages.title', 'Newpages.description', 'Newpages.slug', 'Newpages.slug_plus', 'Newpages.release_date', 'Newpages.modified']) ->where(['Newpages.id' => $id]) ->where(['Newpages.company_id' => $company_data->id]) ->where(['Newpages.display_flag' => 1]) ->where(['Newpages.delete_flag' => 0]) ->first(); }else{ $page_data = $this->Pages->find() ->select(['Pages.id', 'Pages.pagetype_id', 'Pages.parent_id', 'Pages.title', 'Pages.description', 'Pages.slug', 'Pages.slug_plus', 'Pages.release_date', 'Pages.modified']) ->where(['Pages.id' => $id]) ->where(['Pages.company_id' => $company_data->id]) ->where(['Pages.display_flag' => 1]) ->where(['Pages.delete_flag' => 0]) ->first(); } if(!empty($page_data->parent_id)){ //親ページ if($company_data->cms_version >= 1){ $parent_data = $this->Newpages->find() ->select(['Newpages.id', 'Newpages.pagetype_id', 'Newpages.parent_id', 'Newpages.title', 'Newpages.description', 'Newpages.slug', 'Newpages.slug_plus', 'Newpages.release_date', 'Newpages.modified']) ->where(['Newpages.id' => $page_data->parent_id]) ->where(['Newpages.company_id' => $company_data->id]) ->where(['Newpages.display_flag' => 1]) ->where(['Newpages.delete_flag' => 0]) ->first(); }else{ $parent_data = $this->Pages->find() ->select(['Pages.id', 'Pages.pagetype_id', 'Pages.parent_id', 'Pages.title', 'Pages.description', 'Pages.slug', 'Pages.slug_plus', 'Pages.release_date', 'Pages.modified']) ->where(['Pages.id' => $page_data->parent_id]) ->where(['Pages.company_id' => $company_data->id]) ->where(['Pages.display_flag' => 1]) ->where(['Pages.delete_flag' => 0]) ->first(); } $url = 'https://'.$_SERVER['HTTP_HOST'].$parent_data->slug_plus; if($page_data->pagetype_id == 6){ $url = $url.'detail/'.$page_data->slug.'/'; }else{ $url = $url.$page_data->slug.'/'; } }else{ if($page_data->pagetype_id == 4){ $url = 'https://'.$_SERVER['HTTP_HOST'].$page_data->slug_plus; }else{ $url = 'https://'.$_SERVER['HTTP_HOST'].'/'; } } /*$response_data = "\n"; $response_data .= "\n";*/ $response_data = ""; $response_data .= "\n"; $response_data .= "\n"; $response_data .= "\n"; $response_data .= "".strip_tags($page_data->title, '<br>')."\n"; $response_data .= "".$url."\n"; $response_data .= "id."/\" rel=\"self\" type=\"application/rss+xml\" />\n"; $response_data .= "".$page_data->description."\n"; $response_data .= "ja\n"; // $response_data .= "\n"; $response_data .= "".strip_tags($page_data->title)."\n"; $response_data .= "\n"; $response_data .= "description)){ $response_data .= "".$page_data->description."\n"; }else{ $response_data .= "".$page_data->ameblo_content."\n"; } $response_data .= "]]>\n"; $response_data .= "\n"; $response_data .= "".$url."\n"; date_default_timezone_set('Asia/Tokyo'); $pubDate = ''; $pubDate = date("D, d M Y H:i:s", strtotime($page_data->release_date)); $response_data .= "".$pubDate." +0900\n"; $response_data .= "\n"; $response_data .= "\n"; $response_data .= "\n"; } // $this->response->body($response_data); } public function robots(){ $this->autoRender = false; $this->viewBuilder()->autoLayout(false); $this->response->charset('UTF-8'); //ドメインから企業情報を取得 if(isset($_SERVER['HTTP_HOST'])){ $company = $this->Companies->find() ->where(['Companies.domain' => $_SERVER['HTTP_HOST']]) ->where(['Companies.delete_flag' => 0]) ->first(); if($company){ $setting = $this->Settings->find() ->select(['Settings.robots']) ->where(['Settings.company_id' => $company->id]) ->where(['Settings.delete_flag' => 0]) ->first(); if(empty($setting->robots)){ $robots_text = ""; $robots_text .= "User-agent: *\n"; $robots_text .= "Allow: /\n"; $robots_text .= "Sitemap: https://".$_SERVER['HTTP_HOST']."/sitemap/xml/"; }else{ $robots_text = $setting->robots; } } } $this->response->body($robots_text); } //認証を行う function getClient($api_key) { require_once ('/var/www/html/application/lib/google-api-php-client-2.2.0/vendor/autoload.php'); $client = new \Google_Client(); $client->setApplicationName("youtube-api-test"); $client->setDeveloperKey($api_key); return $client; } //Youtube動画を取得する function searchVideos($channel_id, $api_key, $result_num, $page_token, $category){ require_once ('/var/www/html/application/lib/google-api-php-client-2.2.0/vendor/autoload.php'); $youtube = new \Google_Service_YouTube($this->getClient($api_key)); // $params = []; if(!empty($category)){ $params['playlistId'] = $category; }else{ $params['channelId'] = $channel_id; $params['type'] = 'video'; $params['order'] = 'date'; } $params['maxResults'] = $result_num; if(!empty($page_token)){ $params['pageToken'] = $page_token; } //$params['videoCategoryId'] = ''; try { if(!empty($category)){ $searchResponse = $youtube->playlistItems->listPlaylistItems('snippet', $params); }else{ $searchResponse = $youtube->search->listSearch('snippet', $params); } } catch (Google_Service_Exception $e) { echo htmlspecialchars($e->getMessage()); exit; } catch (Google_Exception $e) { echo htmlspecialchars($e->getMessage()); exit; } $return_data = []; $return_data['total_result'] = $searchResponse['pageInfo']['totalResults']; if(isset($searchResponse['prevPageToken']) && !empty($searchResponse['prevPageToken'])){ $return_data['prev'] = $searchResponse['prevPageToken']; }else{ $return_data['prev'] = ''; } if(isset($searchResponse['nextPageToken']) && !empty($searchResponse['nextPageToken'])){ $return_data['next'] = $searchResponse['nextPageToken']; }else{ $return_data['next'] = ''; } $videos = []; foreach ($searchResponse['items'] as $search_result) { //$videos[] = $search_result; $tmp_video = []; if(!empty($category)){ $tmp_video['video_id'] = $search_result->snippet->resourceId->videoId; $tmp_video['title'] = $search_result->snippet->title; $tmp_video['description'] = $search_result->snippet->description; $tmp_video['date'] = $search_result->snippet->publishedAt; }else{ $tmp_video['video_id'] = $search_result->id->videoId; $tmp_video['title'] = $search_result->snippet->title; $tmp_video['description'] = $search_result->snippet->description; $tmp_video['date'] = $search_result->snippet->publishedAt; } $videos[] = $tmp_video; } $return_data['total_result'] = $total_result; $return_data['items'] = $videos; //再生リスト一覧 $params = []; $params['channelId'] = $channel_id; //$params['type'] = 'video'; $params['maxResults'] = 50; //$params['order'] = 'date'; try { $searchResponse = $youtube->playlists->listPlaylists('snippet', $params); } catch (Google_Service_Exception $e) { echo htmlspecialchars($e->getMessage()); exit; } catch (Google_Exception $e) { echo htmlspecialchars($e->getMessage()); exit; } $videos = []; foreach ($searchResponse['items'] as $search_result) { $videos[] = $search_result; } $return_data['categories'] = $videos; // return $return_data; } function cookiePolicy(){ //ドメインから企業情報の取得 $query = $this->Companies->find() ->where(['Companies.status' => 1]) ->where(['Companies.delete_flag' => 0]); //顧客用サブドメインによるアクセスの場合 //if((strpos($_SERVER['HTTP_HOST'],'onerank-cms.com') !== false) && ($_SERVER['HTTP_HOST'] != 'onerank-cms.com')){ if((strpos($_SERVER['HTTP_HOST'],'onerank-cms.com') !== false && $_SERVER['HTTP_HOST'] != 'onerank-cms.com') || (strpos($_SERVER['HTTP_HOST'],'onerank-cms-2.com') !== false && $_SERVER['HTTP_HOST'] != 'onerank-cms-2.com') || (strpos($_SERVER['HTTP_HOST'],'onerank-cms-3.com') !== false && $_SERVER['HTTP_HOST'] != 'onerank-cms-3.com') || (strpos($_SERVER['HTTP_HOST'],'onerank-hybrid-dev.com') !== false && $_SERVER['HTTP_HOST'] != 'onerank-hybrid-dev.com') || (strpos($_SERVER['HTTP_HOST'],'onerank-hybrid-dev2.com') !== false && $_SERVER['HTTP_HOST'] != 'onerank-hybrid-dev2.com') || (strpos($_SERVER['HTTP_HOST'],'onerank-hybrid-dev3.com') !== false && $_SERVER['HTTP_HOST'] != 'onerank-hybrid-dev3.com') || (strpos($_SERVER['HTTP_HOST'],'ip-lambda.org') !== false && $_SERVER['HTTP_HOST'] != 'ip-lambda.org')){ $query->where(['Companies.subdomain' => SUB_DOMAIN]); $domain_name = $_SERVER['HTTP_HOST']; $www_mode = ''; $subdomain_mode = 'on'; //顧客専本ドメインによるアクセスの場合 }else{ //wwwありなしの確認 if(substr($_SERVER['HTTP_HOST'], 0, 4) == 'www.'){ $www_mode = 'on'; $domain_name = str_replace('www.', '', $_SERVER['HTTP_HOST']); }else{ $www_mode = 'off'; $domain_name = $_SERVER['HTTP_HOST']; } //$query->where(['Companies.domain' => $_SERVER['HTTP_HOST']]); $query->where(['Companies.domain' => $domain_name]); $subdomain_mode = 'off'; } $company = $query->first(); // $setting = $this->Settings->find() ->where(['Settings.company_id' => $company->id]) ->first(); // /*$prevention = $this->Preventions->find() ->where(['Preventions.company_id' => $company->id]) ->first();*/ // $this->set('setting', $setting); //$this->set('prevention', $prevention); $this->viewBuilder()->layout('newframe/cookie_policy'); } /* Infobiz基本関数 */ public function authLogin($api_key = null, $username = null, $password = null){ // /*$this->autoRender = false; $this->viewBuilder()->autoLayout(false); $this->response->charset('UTF-8');*/ // $headers = [ //'accept: */*', 'Content-Type: application/json', 'x-api-key:'.$api_key, ]; $post_data = [ 'email' => $username, 'password' => $password, ]; $post_data_json = json_encode($post_data, JSON_UNESCAPED_UNICODE); $curl = curl_init('https://pub-api.optimize-business.com/v1/login'); curl_setopt($curl,CURLOPT_POST, true); // curl_setopt($curl,CURLOPT_POSTFIELDS, $post_data_json); //curl_setopt($curl, CURLOPT_POSTFIELDS, http_build_query($post_data_json)); curl_setopt($curl,CURLOPT_RETURNTRANSFER, TRUE); curl_setopt($curl, CURLOPT_HTTPHEADER, $headers); $response = curl_exec($curl); return $response; } public function getBasicInfo($api_key = null, $token = null, $location_id = null){ // /*$this->autoRender = false; $this->viewBuilder()->autoLayout(false); $this->response->charset('UTF-8');*/ // $headers = [ //'accept: */*', 'Content-Type: application/json', 'x-api-key:'.$api_key, 'authorization: Bearer '.$token ]; /*$post_data = [ 'client_id' => 'es11.api.Zadsghs', 'client_secret' => 'FsGjsjsGJdj@gshjs', 'scope' => 'r_item r_table_activity w_order r_order r_table r_category w_table_activity r_item_detail_content r_item_detail', 'session_id' => $session_id, ]; $post_data_json = json_encode($post_data, JSON_UNESCAPED_UNICODE);*/ $curl = curl_init('https://pub-api.optimize-business.com/v1/basic-information/'.$location_id); //curl_setopt($curl,CURLOPT_POST, true); // //curl_setopt($curl,CURLOPT_POSTFIELDS, $post_data_json); //curl_setopt($curl, CURLOPT_POSTFIELDS, http_build_query($post_data_json)); curl_setopt($curl,CURLOPT_RETURNTRANSFER, TRUE); curl_setopt($curl, CURLOPT_HTTPHEADER, $headers); $response = curl_exec($curl); return $response; } public function getReview($api_key = null, $token = null, $location_id = null){ // /*$this->autoRender = false; $this->viewBuilder()->autoLayout(false); $this->response->charset('UTF-8');*/ // $headers = [ //'accept: */*', 'Content-Type: application/json', 'x-api-key:'.$api_key, 'authorization: Bearer '.$token ]; /*$post_data = [ 'client_id' => 'es11.api.Zadsghs', 'client_secret' => 'FsGjsjsGJdj@gshjs', 'scope' => 'r_item r_table_activity w_order r_order r_table r_category w_table_activity r_item_detail_content r_item_detail', 'session_id' => $session_id, ]; $post_data_json = json_encode($post_data, JSON_UNESCAPED_UNICODE);*/ $curl = curl_init('https://pub-api.optimize-business.com/v1/review/'.$location_id); //$curl = curl_init('https://pub-api.optimize-business.com/v1/review/'); //curl_setopt($curl,CURLOPT_POST, true); // //curl_setopt($curl,CURLOPT_POSTFIELDS, $post_data_json); //curl_setopt($curl, CURLOPT_POSTFIELDS, http_build_query($post_data_json)); curl_setopt($curl,CURLOPT_RETURNTRANSFER, TRUE); curl_setopt($curl, CURLOPT_HTTPHEADER, $headers); $response = curl_exec($curl); return $response; } } ?> Error