Пример #1
0
 public function run()
 {
     $models = explode(',', $this->params['model']);
     $field = $this->params['field'];
     $Analyzer = new SeoLiteAnalyzer();
     foreach ($models as $model) {
         $Model = ClassRegistry::init($model);
         $rows = $Model->find('all', array('recursive' => -1, 'fields' => array($Model->primaryKey, $field)));
         $i = 0;
         foreach ($rows as $row) {
             $result = $Analyzer->analyze($row[$Model->alias][$field]);
             $this->_updateMeta($Model->alias, $row[$Model->alias][$Model->primaryKey], 'meta_keywords', $result['keywords']);
             $this->_updateMeta($Model->alias, $row[$Model->alias][$Model->primaryKey], 'meta_description', $result['description']);
             $i++;
         }
         $this->out(sprintf('Model %s: %d records', $model, $i));
     }
     $this->out('Done');
 }
Пример #2
0
 public function admin_index($plugin = null, $model = null, $id = null, $field = null)
 {
     if (empty($id)) {
         throw new NotFoundException('Invalid id');
     }
     $Model = ClassRegistry::init($plugin . '.' . $model);
     $Model->id = $id;
     $body = $Model->field($field);
     if ($Model->hasField('excerpt')) {
         $excerpt = $Model->field('excerpt');
     }
     $Analyzer = new SeoLiteAnalyzer();
     $result = $Analyzer->analyze($body);
     if (!empty($excerpt)) {
         $result['description'] = $excerpt;
     }
     extract($result);
     $this->set('_rootNode', 'results');
     $this->set(compact('keywords', 'description'));
     $this->set('_serialize', array('keywords', 'description'));
 }