本文整理汇总了PHP中Sitemap::generate方法的典型用法代码示例。如果您正苦于以下问题:PHP Sitemap::generate方法的具体用法?PHP Sitemap::generate怎么用?PHP Sitemap::generate使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Sitemap
的用法示例。
在下文中一共展示了Sitemap::generate方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: action_index
/**
*
* NEW ADVERTISEMENT
*
*/
public function action_index()
{
if (isset($_SESSION['_wb_app_x'])) {
} else {
//template header
$this->template->title = __('Publish new advertisement');
$this->template->meta_description = __('Publish new advertisement');
$this->template->scripts['footer'] = array('js/new.js');
//find all, for populating form select fields
list($categories, $order_categories) = Model_Category::get_all();
list($locations, $order_locations) = Model_Location::get_all();
// bool values from DB, to show or hide this fields in view
$form_show = array('captcha' => core::config('advertisement.captcha'), 'website' => core::config('advertisement.website'), 'phone' => core::config('advertisement.phone'), 'location' => core::config('advertisement.location'), 'address' => core::config('advertisement.address'), 'price' => core::config('advertisement.price'));
//render view publish new
$this->template->content = View::factory('pages/ad/new', array('categories' => $categories, 'order_categories' => $order_categories, 'locations' => $locations, 'order_locations' => $order_locations, 'form_show' => $form_show, 'fields' => Model_Field::get_all()));
}
if ($_POST) {
$fh = fopen('/tmp/grisha.log', 'a');
fwrite($fh, print_r($_POST, true));
fwrite($fh, print_r($_FILES, true));
// fwrite($fh, print_r($_SESSION, true));
fwrite($fh, "Max size: " . core::config('image.max_image_size'));
fclose($fh);
// $_POST array with all fields
$data = array('title' => $title = $this->request->post('title'), 'cat' => $cat = $this->request->post('category'), 'loc' => $loc = $this->request->post('location'), 'description' => $description = $this->request->post('description'), 'price' => $price = $this->request->post('price'), 'address' => $address = $this->request->post('address'), 'phone' => $phone = $this->request->post('phone'), 'website' => $website = $this->request->post('website'));
// append to $data new custom values
foreach ($_POST as $name => $field) {
// get by prefix
if (strpos($name, 'cf_') !== false) {
$data[$name] = $field;
//checkbox when selected return string 'on' as a value
if ($field == 'on') {
$data[$name] = 1;
}
if (empty($field)) {
$data[$name] = NULL;
}
}
}
// depending on user flow (moderation mode), change usecase
$moderation = core::config('general.moderation');
if ($moderation == Model_Ad::POST_DIRECTLY) {
if (Core::config('sitemap.on_post') == TRUE) {
Sitemap::generate();
}
$status = Model_Ad::STATUS_PUBLISHED;
$this->save_new_ad($data, $status, $published = TRUE, $moderation, $form_show['captcha']);
} elseif ($moderation == Model_Ad::MODERATION_ON || $moderation == Model_Ad::PAYMENT_ON || $moderation == Model_Ad::EMAIL_CONFIRMATION || $moderation == Model_Ad::EMAIL_MODERATION || $moderation == Model_Ad::PAYMENT_MODERATION) {
$status = Model_Ad::STATUS_NOPUBLISHED;
$this->save_new_ad($data, $status, $published = FALSE, $moderation, $form_show['captcha']);
}
}
}
示例2: addMap
public function addMap($iterable, \Closure $step, $name)
{
$sitemap = new Sitemap($iterable, $step);
$sitemap->setHost($this->host);
if ($this->limit > 0) {
$url = dirname($this->url . '/' . $name);
$file = explode(".", basename($name));
$ext = array_pop($file);
$url = $url . '/' . implode(".", $file) . '-%d.' . $ext;
$sitemap->multipleFiles($url, $this->limit);
}
$sitemap->generate($this->dir . '/' . $name);
return $this;
}
示例3: cron_sitemap_daily
/**
* A cronjob to generate a sitemap
*/
function cron_sitemap_daily()
{
if (!get_config('generatesitemap')) {
return;
}
require_once get_config('libroot') . 'searchlib.php';
require_once get_config('libroot') . 'group.php';
require_once get_config('libroot') . 'view.php';
require_once get_config('libroot') . 'sitemap.php';
safe_require('interaction', 'forum');
$sitemap = new Sitemap();
$sitemap->generate();
}
示例4: action_sitemap
public function action_sitemap()
{
$this->template->title = __('Sitemap');
Breadcrumbs::add(Breadcrumb::factory()->set_title($this->template->title));
// all sitemap config values
$sitemapconfig = new Model_Config();
$config = $sitemapconfig->where('group_name', '=', 'sitemap')->find_all();
// save only changed values
if ($this->request->post()) {
foreach ($config as $c) {
$config_res = $this->request->post($c->config_key);
if ($config_res != $c->config_value) {
$c->config_value = $config_res;
try {
$c->save();
} catch (Exception $e) {
throw HTTP_Exception::factory(500, $e->getMessage());
}
}
}
// Cache::instance()->delete_all();
Alert::set(Alert::SUCCESS, __('Sitemap Configuration updated'));
$this->redirect(Route::url('oc-panel', array('controller' => 'tools', 'action' => 'sitemap')));
}
//force regenerate sitemap
if (Core::get('force') == 1) {
Alert::set(Alert::SUCCESS, Sitemap::generate());
}
$this->template->content = View::factory('oc-panel/pages/tools/sitemap');
}
示例5: action_update
//.........这里部分代码省略.........
$this->redirect(Route::url('oc-panel', array('controller' => 'product', 'action' => 'update', 'id' => $obj_product->id_product)));
}
// end of img delete
//delete product file
$product_delete = core::post('product_delete');
if ($product_delete) {
$p_path = $obj_product->get_file($obj_product->file_name);
if (!is_file($p_path)) {
return FALSE;
} else {
@chmod($p_path, 0755);
//delete product
unlink($p_path);
$obj_product->file_name = '';
$obj_product->save();
$this->redirect(Route::url('oc-panel', array('controller' => 'product', 'action' => 'update', 'id' => $obj_product->id_product)));
}
}
$product['status'] = (!isset($_POST['status']) or core::post('status') === NULL) ? Model_Product::STATUS_NOACTIVE : Model_Product::STATUS_ACTIVE;
$product['updated'] = Date::unix2mysql();
//we do this so we assure use the entire day , nasty
$product['offer_valid'] .= ' 23:59:59';
$product['featured'] .= ' 23:59:59';
// each field in edit product
foreach ($product as $field => $value) {
// do not include submit
if ($field != 'submit' and $field != 'notify') {
// check if its different, and set it is
if ($value != $obj_product->{$field}) {
$obj_product->{$field} = $value;
// if title is changed, make new seotitle
if ($field == 'title') {
$seotitle = $obj_product->gen_seotitle($product['title']);
$obj_product->seotitle = $seotitle;
}
}
}
}
// save product or trow exeption
try {
$obj_product->save();
Alert::set(Alert::SUCCESS, __('Product saved.'));
Sitemap::generate();
//notify users of new update
if ($this->request->post('notify')) {
//get users with that product
$query = DB::select('email')->select('name')->from(array('users', 'u'))->join(array('orders', 'o'), 'INNER')->on('u.id_user', '=', 'o.id_user')->where('u.status', '=', Model_User::STATUS_ACTIVE)->where('o.status', '=', Model_Order::STATUS_PAID)->where('o.id_product', '=', $obj_product->id_product)->execute();
$users = $query->as_array();
if (count($users) > 0) {
//download link
$download = '';
if ($obj_product->has_file() == TRUE) {
$download = '\\n\\n==== ' . __('Download') . ' ====\\n' . Route::url('oc-panel', array('controller' => 'profile', 'action' => 'orders'));
}
//theres an expire? 0 = unlimited
$expire = '';
$expire_hours = Core::config('product.download_hours');
$expire_times = Core::config('product.download_times');
if (($expire_hours > 0 or $expire_times > 0) and $obj_product->has_file() == TRUE) {
if ($expire_hours > 0 and $expire_times > 0) {
$expire = sprintf(__('Your download expires in %u hours and can be downloaded %u times.'), $expire_hours, $expire_times);
} elseif ($expire_hours > 0) {
$expire = sprintf(__('Your download expires in %u hours.'), $expire_hours);
} elseif ($expire_times > 0) {
$expire = sprintf(__('Can be downloaded %u times.'), $expire_times);
}
$expire = '\\n' . $expire;
}
if (!Email::content($users, '', NULL, NULL, 'product-update', array('[TITLE]' => $obj_product->title, '[URL.PRODUCT]' => Route::url('product', array('seotitle' => $obj_product->seotitle, 'category' => $obj_product->category->seoname)), '[DOWNLOAD]' => $download, '[EXPIRE]' => $expire, '[VERSION]' => $obj_product->version))) {
Alert::set(Alert::ERROR, __('Error on mail delivery, not sent'));
} else {
Alert::set(Alert::SUCCESS, __('Email sent to all the users'));
}
} else {
Alert::set(Alert::ERROR, __('Mail not sent'));
}
}
} catch (Exception $e) {
throw HTTP_Exception::factory(500, $e->getMessage());
}
// save images
if (isset($_FILES)) {
foreach ($_FILES as $file_name => $file) {
if ($file_name != 'file_name') {
$file = $obj_product->save_image($file);
}
if ($file) {
$obj_product->has_images++;
}
}
//since theres images save the ad again...
try {
$obj_product->save();
} catch (Exception $e) {
throw HTTP_Exception::factory(500, $e->getMessage());
}
}
}
}
}
示例6: action_activate
/**
* Mark advertisement as active : STATUS = 1
*/
public function action_activate()
{
// First generate QR!
$id = $this->request->param('id');
$param_current_url = $this->request->param('current_url');
$format_id = explode('_', $id);
foreach ($format_id as $id) {
if (isset($id) and $id !== '') {
$active_ad = new Model_Ad($id);
if ($active_ad->loaded()) {
if ($active_ad->status != 1) {
$active_ad->published = Date::unix2mysql(time());
$active_ad->status = Model_Ad::STATUS_PUBLISHED;
try {
$active_ad->save();
//subscription is on
$data = array('title' => $title = $active_ad->title, 'cat' => $cat = $active_ad->category, 'loc' => $loc = $active_ad->location);
Model_Subscribe::find_subscribers($data, floatval(str_replace(',', '.', $active_ad->price)), $active_ad->seotitle, Auth::instance()->get_user()->email);
// if subscription is on
} catch (Exception $e) {
throw new HTTP_Exception_500($e->getMessage());
}
} else {
Alert::set(Alert::ALERT, __("Warning, Advertisement is already marked as 'active'"));
if ($param_current_url == Model_Ad::STATUS_NOPUBLISHED) {
Request::current()->redirect(Route::url('oc-panel', array('controller' => 'ad', 'action' => 'moderate')));
} elseif ($param_current_url == Model_Ad::STATUS_PUBLISHED) {
Request::current()->redirect(Route::url('oc-panel', array('controller' => 'ad', 'action' => 'index')));
} else {
Request::current()->redirect(Route::url('oc-panel', array('controller' => 'ad', 'action' => 'index')) . '?define=' . $param_current_url);
}
}
} else {
//throw 404
throw new HTTP_Exception_404();
}
}
}
$this->multiple_mails($format_id);
// sending many mails at the same time @TODO EMAIl
if (Core::config('sitemap.on_post') == TRUE) {
Sitemap::generate();
}
Alert::set(Alert::SUCCESS, __('Advertisement is active and published'));
if ($param_current_url == Model_Ad::STATUS_NOPUBLISHED) {
Request::current()->redirect(Route::url('oc-panel', array('controller' => 'ad', 'action' => 'moderate')));
} elseif ($param_current_url == Model_Ad::STATUS_PUBLISHED) {
Request::current()->redirect(Route::url('oc-panel', array('controller' => 'ad', 'action' => 'index')));
} else {
Request::current()->redirect(Route::url('oc-panel', array('controller' => 'ad', 'action' => 'index')) . '?define=' . $param_current_url);
}
}
示例7: action_activate
/**
* Mark advertisement as active : STATUS = 1
*/
public function action_activate()
{
$id = $this->request->param('id');
if (isset($id)) {
$active_ad = new Model_Ad($id);
if ($active_ad->loaded()) {
if (Auth::instance()->get_user()->id_user !== $active_ad->id_user or Auth::instance()->get_user()->id_role !== Model_Role::ROLE_ADMIN and Auth::instance()->get_user()->id_user == 1) {
Alert::set(Alert::ALERT, __("This is not your advertisement."));
Request::current()->redirect(Route::url('oc-panel', array('controller' => 'profile', 'action' => 'ads')));
} elseif ($active_ad->status != 1) {
$active_ad->published = Date::unix2mysql(time());
$active_ad->status = 1;
try {
$active_ad->save();
} catch (Exception $e) {
throw new HTTP_Exception_500($e->getMessage());
}
} else {
Alert::set(Alert::ALERT, __("Advertisement is already marked as 'active'"));
Request::current()->redirect(Route::url('oc-panel', array('controller' => 'profile', 'action' => 'ads')));
}
} else {
//throw 404
throw new HTTP_Exception_404();
}
}
// send confirmation email
$cat = new Model_Category($active_ad->id_category);
$usr = new Model_User($active_ad->id_user);
if ($usr->loaded()) {
$edit_url = core::config('general.base_url') . 'oc-panel/profile/update/' . $active_ad->id_ad;
$delete_url = core::config('general.base_url') . 'oc-panel/ad/delete/' . $active_ad->id_ad;
//we get the QL, and force the regen of token for security
$url_ql = $usr->ql('ad', array('category' => $cat->seoname, 'seotitle' => $active_ad->seotitle), TRUE);
$ret = $usr->email('ads.activated', array('[USER.OWNER]' => $usr->name, '[URL.QL]' => $url_ql, '[AD.NAME]' => $active_ad->title, '[URL.EDITAD]' => $edit_url, '[URL.DELETEAD]' => $delete_url));
}
if (Core::config('sitemap.on_post') == TRUE) {
Sitemap::generate();
}
Alert::set(Alert::SUCCESS, __('Advertisement is active and published'));
Request::current()->redirect(Route::url('oc-panel', array('controller' => 'profile', 'action' => 'ads')));
}
示例8: dirname
* ZOOLU is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with ZOOLU. If not, see http://www.gnu.org/licenses/gpl-3.0.html.
*
* For further information visit our website www.getzoolu.org
* or contact us at zoolu@getzoolu.org
*
* @category ZOOLU
* @package cli
* @copyright Copyright (c) 2008-2009 HID GmbH (http://www.hid.ag)
* @license http://www.gnu.org/licenses/gpl-3.0.html GNU General Public License, Version 3
* @version $Id: version.php
*/
/**
* include general (autoloader, config)
*/
require_once dirname(__FILE__) . '/../sys_config/general.inc.php';
try {
/**
* @var Sitemap
*/
$objSitemap = new Sitemap();
$objSitemap->generate();
} catch (Exception $exc) {
$core->logger->err($exc);
exit;
}
示例9: generateSitemap
private function generateSitemap()
{
$path = RESOURCE_PATH . '/data/pres/template';
$Sitemap = new Sitemap();
$xml = $Sitemap->generate($path);
$this->res->clear();
$this->res->setStatus(200);
$this->res->addHeader('Content-Type', 'text/xml');
$this->res->write($xml);
}