Webylon 3.2 API Docs
  • Package
  • Class
  • Tree
  • Deprecated
  • Download
Version: current
  • 3.2
  • 3.1

Packages

  • 1c
    • exchange
      • catalog
  • auth
  • Booking
  • building
    • company
  • cart
    • shipping
    • steppedcheckout
  • Catalog
    • monument
  • cms
    • assets
    • batchaction
    • batchactions
    • bulkloading
    • comments
    • content
    • core
    • export
    • newsletter
    • publishers
    • reports
    • security
    • tasks
  • Dashboard
  • DataObjectManager
  • event
  • faq
  • forms
    • actions
    • core
    • fields-basic
    • fields-dataless
    • fields-datetime
    • fields-files
    • fields-formatted
    • fields-formattedinput
    • fields-relational
    • fields-structural
    • transformations
    • validators
  • googlesitemaps
  • guestbook
  • installer
  • newsletter
  • None
  • photo
    • gallery
  • PHP
  • polls
  • recaptcha
  • sapphire
    • api
    • bulkloading
    • control
    • core
    • cron
    • dev
    • email
    • fields-formattedinput
    • filesystem
    • formatters
    • forms
    • i18n
    • integration
    • misc
    • model
    • parsers
    • search
    • security
    • tasks
    • testing
    • tools
    • validation
    • view
    • widgets
  • seo
    • open
      • graph
  • sfDateTimePlugin
  • spamprotection
  • stealth
    • captha
  • subsites
  • userform
    • pagetypes
  • userforms
  • webylon
  • widgets

Classes

  • Announcement_Controller
  • AnnouncementHolder_Controller
  • BookingAdminPage_Controller
  • BookingPage_Controller
  • Cart_Controller
  • CartPage_Controller
  • Catalog_Controller
  • CheckoutPage_Controller
  • ChequePayment_Handler
  • ContactsPage_Controller
  • ContentController
  • ContentNegotiator
  • Controller
  • DataObjectManager_Controller
  • DatePickerField_Controller
  • Director
  • DocPage_Controller
  • DocumentsPage_Controller
  • Event_Controller
  • EventHolder_Controller
  • FavoritePage_Controller
  • FileDataObjectManager_Controller
  • FindCyrillic_Controller
  • HomePage_Controller
  • Import1C_Controller
  • ImportCatalog1C_Controller
  • LastDoc_Controller
  • LiveCalendarWidget_Controller
  • MapObject_Controller
  • MapObjectGroup_Controller
  • MapPage_Controller
  • MediawebPage_Controller
  • ModelAsController
  • Monument_Controller
  • MonumentCatalog_Controller
  • MonumentForm_Controller
  • MultiUploadControls
  • NewsArchive_Controller
  • NewsEntry_Controller
  • NewsHolder_Controller
  • Orders1CExchange_Controller
  • Page_Controller
  • Payment_Handler
  • PhotoAlbumManager_Controller
  • Product_Controller
  • ProductSearchPage_Controller
  • ProfilePage_Controller
  • PublHolder_Controller
  • Publication_Controller
  • RatingExtension_Controller
  • RegistrationPage_Controller
  • RemoveOrphanedPagesTask
  • RequestHandler
  • Room_Controller
  • RoomCatalog_Controller
  • RootURLController
  • SapphireInfo
  • Search_Controller
  • Session
  • SimpleOrderPage_Controller
  • SiteMap_Controller
  • Socle_Controller
  • SocleSize_Controller
  • SpecialCatalog_Controller
  • SS_HTTPRequest
  • SS_HTTPResponse
  • StartCatalog_Controller
  • SubsitesSelectorPage_Controller
  • VideoBankPage_Controller

Interfaces

  • NestedController

Exceptions

  • SS_HTTPResponse_Exception
  1 <?php
  2 
  3 class FindCyrillic_Controller extends Controller {
  4     
  5     public static $allowed_actions = array(
  6         'index',
  7     );
  8 
  9     public function __construct(){
 10         parent::__construct();
 11     }
 12 
 13 
 14     public function index(SS_HTTPRequest $request){
 15         if(Director::isDev()){
 16             $task = new FindCyrillic();
 17             $task->process();
 18         }
 19         Director::redirectBack();
 20     }
 21 }
 22 
 23 
 24 
 25 class FindCyrillic extends ScheduledTask {
 26 
 27     static $skipDirs = array(
 28         'node_modules',
 29         'assets',
 30         'import',
 31         'offers',
 32         'css',
 33         'css-styl',
 34         'js',
 35         'js-dev',
 36         '.svn',
 37         'lang',
 38         'dicts',
 39         'javascript',
 40         'sapphire',
 41         'thirdparty',
 42         'img',
 43         'threejs',
 44         'silverstripe-cache'
 45     );
 46     protected $body  = '';
 47 
 48     function process(){
 49         $siteRoot = trim(Director::absoluteBaseURL(),'/');
 50 
 51         // Поиск по файлам
 52         $path = BASE_PATH . '/';
 53         $this->body  .= "<details>";
 54         $this->body  .= "<summary>Файлы с кириллицей</summary>";
 55         $this->body  .= "<ol>";
 56         $this->fetchDir($path);
 57         $this->body  .= "</ol>";
 58         $this->body  .= "</details>";
 59 
 60         if(!in_array("SubsiteAdmin", get_declared_classes())){
 61             die('doge');
 62         }
 63 
 64         Subsite::$disable_subsite_filter = true;
 65         $subsites = array();
 66         $items = DataObject::get('Subsite');
 67         foreach ($items as $subsite) {
 68             if($subsite->Language != 'ru_RU'){
 69                 $subsites[$subsite->ID] = $subsite->getPrimaryDomain();
 70             }
 71         }
 72 
 73         $tables = DB::query('SHOW TABLES');
 74         $tables = $tables->column();
 75 // $this->body  .= "<details>";
 76 // $this->body  .= "<summary>Кириллица в контенте</summary>";
 77 $this->body  .= "Кириллица в контенте";
 78 $this->body  .= "<ol>";
 79 
 80         foreach ($subsites as $ID => $domain) {
 81             $pages = Versioned::get_by_stage('SiteTree', 'Live', "Status = 'Published' AND SubsiteID = {$ID}");
 82             if(!$pages || !$pages->Count()){
 83                 continue;
 84             }
 85             // $pages = DataObject::get('SiteTree',"Status = 'Published' AND SubsiteID = {$ID}");
 86             // $page = $pages->pop();
 87             // var_dump($page->ID);
 88             // var_dump($pages->TotalItems());
 89             // die();
 90             // $iterator = $pages->getIterator();
 91             // $iterator = $pages->toArray();
 92             // foreach ($iterator as $page) {
 93             foreach ($pages as $page) {
 94             // while($page = $pages->pop()) {
 95                 $fields = array();
 96 
 97                 $fieldLabels = $page->fieldLabels();
 98                 $has_one = $page->has_one();
 99                 $has_many = $page->has_many();
100                 $many_many = $page->many_many();
101                 $belongs_to = $page->belongs_to();
102                 $data = array();
103                 $data[] = $has_one;
104                 $data[] = $has_many;
105                 $data[] = $many_many;
106                 $data[] = $belongs_to;
107 
108                 foreach ($data as $item) {
109                     foreach ($item as $key => $value) {
110                         if(in_array($value, array('SiteTree', 'Subsite', 'Group', 'Folder'))){
111                             continue;
112                         }
113                         foreach ($page->$key() as $relatedObject) {
114                             $t = $relatedObject->fieldLabels();
115                             foreach ($t as $relatedKey => $relatedValue) {
116                                 if($relatedKey == 'Title' && $relatedObject->ClassName == 'Image'){
117                                     continue;
118                                 }
119                                 if($this->isCyrillic($relatedObject->$relatedKey)){
120                                     $fields[$page->Title.'----'.$page->ClassName]['Related'][] = $relatedObject->ClassName . ":" . $relatedValue . ':' . $relatedObject->ID;
121                                     
122                                 }
123                             }
124                         }
125                     }
126                 }
127                 foreach ($fieldLabels as $key => $value) {
128                     if($this->isCyrillic($page->$key)){
129                         // $fields[$page->ClassName]['Fields'][] = $key;
130                         $fields[$page->Title.'----'.$page->ClassName]['Fields'][] = $value;
131                     }
132                 }
133                 if(!empty($fields)){
134 
135 
136                     foreach ($fields as $key => $value) {
137                         $exploded = explode('----', $key);
138                         $title = $exploded[0];
139                         $type = $exploded[1];
140                             $this->body  .= "
141     <li><strong>{$title}</strong> - {$type} - <a target='_blank' href='{$siteRoot}{$domain}/{$page->URLSegment}'>Ссылка на страницу</a> (<a target='_blank' href='{$siteRoot}/admin/show/{$page->ID}'>Админка</a>)";
142                         if(isset($value['Fields']) && !empty($value['Fields'])){
143 
144                             $fieldsList = implode("</li><li>", $value['Fields']);
145         $this->body  .= "<ul>
146             <u>Название поля на странице</u>
147             <li>
148                 {$fieldsList}
149             </li>
150         </ul>";
151                         }
152                         if(isset($value['Related']) && !empty($value['Related'])){
153                         $related = implode("</li><li>", $value['Related']);
154                         $this->body  .= "
155     <ul>
156         <u>Связанные обьекты (Тип:Поле:ID обьекта)</u>
157         <li>
158             {$related}
159         </li>
160     </ul>
161 </li>
162 ";
163                         }
164                     }
165 //                  
166                 }
167 
168             }
169         }
170         $this->body  .= "</ol>";
171         // $this->body  .= "</details>";
172 
173         $sc = SiteConfig::current_site_config();
174         if(isset($sc->EmailForReports) && !empty($sc->EmailForReports)){
175             $to = $sc->EmailForReports;
176         }else{
177             $to = 'test@mediaweb.ru';
178         }
179         $mail = new Email();
180         $mail->setFrom('FindCyrillic@mediaweb.ru');
181         $mail->setSubject("Кириллица на сайте");
182         $mail->setTo($to);
183         // $mail->setTemplate('projectsToModerate');
184         $mail->setBody($this->body);
185         $mail->send();
186     }
187 
188     function fetchDir($path){
189         $files = scandir($path);
190         unset($files[array_search(".", $files)]);
191         unset($files[array_search("..", $files)]);
192         foreach ($files as $file) {
193 
194             if(in_array($file, self::$skipDirs) || is_link($path.$file)){
195                 continue;
196             }
197 
198             if(is_dir($path.$file)){
199                 $this->fetchDir($path.$file.'/');
200             }else{
201                 $i = 0;
202                 $filename = $path.$file;
203                 $fp = fopen($filename, 'r');
204                 while(!feof($fp)){
205                     
206                     $i++;
207                     
208                     $line = trim(fgets($fp));
209                     if(strpos($line,'//') === 0){
210                         continue;
211                     }
212                     
213                     if(strpos($line,'#') === 0){
214                         continue;
215                     }
216 
217                     if(strpos($line,'<%--') === 0){
218                         continue;
219                     }
220 
221                     if(strpos($line,'*') === 0){
222                         continue;
223                     }
224 
225                     if($this->isCyrillic($line)){
226                         // if(preg_match( "/_t\(.*[а-яё].*\)/iu", $line)){
227                         //  continue;
228                         // }    
229                         // $this->body  .= $line;
230                         $this->body  .= "<li>{$filename}:{$i}</li>";
231                         // die();               
232                     }
233                 }
234                 fclose($fp);
235             }
236         }
237     }
238 
239     function isCyrillic($line){
240 
241         if(preg_match( "/[\#|\/\/].*[а-яё]{2,}/iu", $line)){
242             return false;
243         }
244 
245         if(preg_match( "/_t\(.*[а-яё]{2,}/iu", $line)){
246             return false;
247         }
248 
249         if(preg_match( "/[а-яё]{2,}/iu", $line)){
250             return true;
251         }
252         return false;
253     }
254 }
[Raise a SilverStripe Framework issue/bug](https://github.com/silverstripe/silverstripe-framework/issues/new)
- [Raise a SilverStripe CMS issue/bug](https://github.com/silverstripe/silverstripe-cms/issues/new)
- Please use the Silverstripe Forums to ask development related questions. -
Webylon 3.2 API Docs API documentation generated by ApiGen 2.8.0