protected function execute($arguments = array(), $options = array()) { $app = $arguments['application']; $env = $options['env']; $this->bootstrapSymfony($app, $env, true); // initialize the database connection $databaseManager = new sfDatabaseManager($this->configuration); $connection = $databaseManager->getDatabase('doctrine')->getConnection(); $q = Doctrine_Query::create()->select('*')->from('SeoPage'); if (isset($options['id'])) { $pages = $q->addWhere('id = ?', $options['id']); } if (isset($options['where'])) { $pages = $q->addWhere(str_replace('is', '=', $options['where'])); } $pages = $q->execute(); if (!$pages->count() && isset($options['id'])) { $this->logSection('seo', 'Page of id "' . $options['id'] . '" not found.'); return 1; } $browser = new SeoTestFunctional(new SeoTaskBrowser()); $updated = array(); $missing = array(); foreach ($pages as $page) { $browser->loadUrl($page['url']); if ($browser->isStatusCode(200)) { $new = SeoToolkit::createMetaData($browser->getContent()); if ($page['title'] != $new['title'] || $page['description'] != $new['description'] || $page['keywords'] != $new['keywords']) { $page->fromArray($new); $update[] = $page; } } else { $missing[] = $page; } } $num_up = (int) count($update); $num_miss = (int) count($missing); $total = $pages->count(); if ($num_up) { if (!(isset($options['no-confirmation']) && $options['no-confirmation']) && !$this->askConfirmation(array('This command will update ' . $num_up . ' page(s) in your database.', 'Are you sure you want to proceed? (y/N)'), null, false)) { $this->logSection('seo', 'task aborted'); return 1; } foreach ($update as $page) { $page->save(); } $this->logSection('seo', $num_up . ' of ' . $total . ' were updated'); } else { $this->logSection('seo', 'All of your pages metas are up to date'); } if ($num_miss) { $this->logSection('seo', 'Missing Pages Found', null, 'ERROR'); $this->removePages($missing, $options); } $this->logSection('seo', 'Task Complete'); }
/** * executeMeta_data_admin_bar * * Be careful calling this component individually, you may add an unnecessary query to every page * * @param sfWebRequest $request * @return void * @author Brent Shaffer */ public function executeSeo_admin_bar(sfWebRequest $request) { if (sfConfig::get('app_csSEOToolkitPlugins_IncludeAssets', true)) { $this->includeAdminBarAssets($request); } if (!isset($this->page)) { $this->page = SeoToolkit::getCurrentSeoPage($request); } $this->metaform = new MetaDataForm($this->page); $this->sitemapform = new SitemapItemForm($this->page); $this->validated = $this->validatedUser(); }
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9"> <?php foreach ($items as $item) { ?> <url> <loc><?php echo url_for(SeoToolkit::xmlencode($item->url)); ?> </loc> <changeFreq><?php echo $item['changeFreq']; ?> </changeFreq> <priority><?php echo $item['priority']; ?> </priority> <lastmod><?php echo $item['updated_at']; ?> </lastmod> </url> <?php } ?> </urlset>
<?php include_http_metas(); ?> <!-- user-set / autogen metas --> <?php if ($meta = get_component('csSEO', 'metas', array())) { ?> <?php echo $meta; } elseif ($sf_response->getStatusCode() == 200) { ?> <?php SeoToolkit::generateMetaData($sf_content, $sf_request); ?> <?php include_component('csSEO', 'metas', array()); }