当前位置: 首页>>代码示例>>PHP>>正文


PHP aTools::slugify方法代码示例

本文整理汇总了PHP中aTools::slugify方法的典型用法代码示例。如果您正苦于以下问题:PHP aTools::slugify方法的具体用法?PHP aTools::slugify怎么用?PHP aTools::slugify使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在aTools的用法示例。


在下文中一共展示了aTools::slugify方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: doClean

 /**
  * @see sfValidatorBase
  */
 protected function doClean($value)
 {
     $clean = (string) parent::doClean($value);
     $clean = aTools::strtolower($clean);
     $slugified = aTools::slugify($clean, $this->getOption('allow_slashes'));
     if ($this->getOption('strict')) {
         if ($slugified !== $clean) {
             throw new sfValidatorError($this, 'invalid', array('value' => $value));
         }
     } else {
         $clean = $slugified;
     }
     return $clean;
 }
开发者ID:quafzi,项目名称:timpany-prototype,代码行数:17,代码来源:aValidatorSlug.class.php

示例2: addCategory

 public function addCategory($name, $blog_id, $type = 'posts')
 {
     $category = current($this->sql->query("SELECT * FROM a_category where name = :name", array('name' => $name)));
     if ($category) {
         $category_id = $category['id'];
     } else {
         $s = "INSERT INTO a_category (name, created_at, updated_at, slug) ";
         $s .= "VALUES (:name, :created_at, :updated_at, :slug)";
         $params = array('name' => $name, 'created_at' => aDate::mysql(), 'updated_at' => aDate::mysql(), 'slug' => aTools::slugify($name));
         $this->sql->query($s, $params);
         $category_id = $this->sql->lastInsertId();
     }
     $s = 'INSERT INTO a_blog_item_to_category (blog_item_id, category_id) VALUES(:blog_item_id, :category_id) ON DUPLICATE KEY UPDATE blog_item_id=blog_item_id';
     $parms = array('blog_item_id' => $blog_id, 'category_id' => $category_id);
     $this->sql->query($s, $parms);
     return $category_id;
 }
开发者ID:existanze,项目名称:apostropheBlogPlugin,代码行数:17,代码来源:aBlogImporter.class.php

示例3: migrate

 public static function migrate()
 {
     $migrate = new aMigrate(Doctrine_Manager::connection()->getDbh());
     $blogIsNew = false;
     echo "Migrating apostropheBlogPlugin...\n";
     if (!$migrate->tableExists('a_blog_item')) {
         $migrate->sql(array("        CREATE TABLE a_blog_editor (blog_item_id BIGINT, user_id BIGINT, PRIMARY KEY(blog_item_id, user_id)) DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci ENGINE = INNODB;", "CREATE TABLE a_blog_item (id BIGINT AUTO_INCREMENT, author_id BIGINT, page_id BIGINT, title VARCHAR(255) NOT NULL, slug_saved TINYINT(1) DEFAULT '0', excerpt TEXT, status VARCHAR(255) DEFAULT 'draft' NOT NULL, allow_comments TINYINT(1) DEFAULT '0' NOT NULL, template VARCHAR(255) DEFAULT 'singleColumnTemplate', published_at DATETIME, type VARCHAR(255), start_date DATE, start_time TIME, end_date DATE, end_time TIME, created_at DATETIME NOT NULL, updated_at DATETIME NOT NULL, slug VARCHAR(255), INDEX a_blog_item_type_idx (type), UNIQUE INDEX a_blog_item_sluggable_idx (slug), INDEX author_id_idx (author_id), INDEX page_id_idx (page_id), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci ENGINE = INNODB;", "        ALTER TABLE a_blog_editor ADD CONSTRAINT a_blog_editor_user_id_sf_guard_user_id FOREIGN KEY (user_id) REFERENCES sf_guard_user(id);", "        ALTER TABLE a_blog_editor ADD CONSTRAINT a_blog_editor_blog_item_id_a_blog_item_id FOREIGN KEY (blog_item_id) REFERENCES a_blog_item(id);", "        ALTER TABLE a_blog_item ADD CONSTRAINT a_blog_item_page_id_a_page_id FOREIGN KEY (page_id) REFERENCES a_page(id) ON DELETE CASCADE;", "        ALTER TABLE a_blog_item ADD CONSTRAINT a_blog_item_author_id_sf_guard_user_id FOREIGN KEY (author_id) REFERENCES sf_guard_user(id) ON DELETE SET NULL;"));
     }
     if (!$migrate->columnExists('a_blog_item', 'location')) {
         $migrate->sql(array('ALTER TABLE a_blog_item ADD COLUMN location varchar(300)'));
     }
     if (!$migrate->columnExists('a_blog_item', 'start_time')) {
         $migrate->sql(array('ALTER TABLE a_blog_item ADD COLUMN start_time TIME', 'ALTER TABLE a_blog_item ADD COLUMN end_time TIME'));
     }
     if (!$migrate->tableExists('a_page_to_category')) {
         $migrate->sql(array("CREATE TABLE a_page_to_category (page_id BIGINT, category_id BIGINT, PRIMARY KEY(page_id, category_id)) ENGINE = INNODB;"));
     }
     if (!$migrate->tableExists('a_blog_item_to_category')) {
         $migrate->sql(array("CREATE TABLE a_blog_item_to_category (blog_item_id BIGINT, category_id BIGINT, PRIMARY KEY(blog_item_id, category_id)) DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci ENGINE = INNODB;", "ALTER TABLE a_blog_item_to_category ADD CONSTRAINT a_blog_item_to_category_category_id_a_category_id FOREIGN KEY (category_id) REFERENCES a_category(id) ON DELETE CASCADE;", "ALTER TABLE a_blog_item_to_category ADD CONSTRAINT a_blog_item_to_category_blog_item_id_a_blog_item_id FOREIGN KEY (blog_item_id) REFERENCES a_blog_item(id) ON DELETE CASCADE;"));
         echo "Migrating blog categories to Apostrophe categories...\n";
         $oldCategories = array();
         if ($migrate->tableExists('a_blog_category')) {
             $oldCategories = $migrate->query('SELECT * FROM a_blog_category');
         }
         $newCategories = $migrate->query('SELECT * FROM a_category');
         $nc = array();
         foreach ($newCategories as $newCategory) {
             $nc[$newCategory['name']] = $newCategory;
         }
         $oldIdToNewId = array();
         foreach ($oldCategories as $category) {
             if (isset($nc[$category['name']])) {
                 $oldIdToNewId[$category['id']] = $nc[$category['name']]['id'];
             } else {
                 // Blog categories didn't have slugs
                 $category['slug'] = aTools::slugify($category['name']);
                 $migrate->query('INSERT INTO a_category (name, description, slug) VALUES (:name, :description, :slug)', $category);
                 $oldIdToNewId[$category['id']] = $migrate->lastInsertId();
             }
         }
         echo "Migrating from aBlogItemCategory to aBlogItemToCategory...\n";
         if ($migrate->tableExists('a_blog_item_category')) {
             $oldMappings = $migrate->query('SELECT * FROM a_blog_item_category');
             foreach ($oldMappings as $info) {
                 $info['category_id'] = $oldIdToNewId[$info['blog_category_id']];
                 $migrate->query('INSERT INTO a_blog_item_to_category (blog_item_id, category_id) VALUES (:blog_item_id, :category_id)', $info);
             }
         }
     }
     // Older updates may not have categories on the virtual page
     $blogPagesById = array();
     $blogPageIdInfos = $migrate->query("SELECT id, page_id FROM a_blog_item");
     foreach ($blogPageIdInfos as $info) {
         $blogPagesById[$info['id']] = $info['page_id'];
     }
     $blogToCategories = $migrate->query("SELECT * FROM a_blog_item_to_category");
     foreach ($blogToCategories as $toCategory) {
         $migrate->query("INSERT INTO a_page_to_category (category_id, page_id) VALUES (:category_id, :page_id) ON DUPLICATE KEY UPDATE category_id = category_id", array('category_id' => $toCategory['category_id'], 'page_id' => $blogPagesById[$toCategory['blog_item_id']]));
     }
     // Older versions did not have taggings on the virtual page
     $blogTaggings = $migrate->query("SELECT * FROM tagging WHERE taggable_model IN ('aBlogPost', 'aEvent')");
     $blogTagsById = array();
     foreach ($blogTaggings as $tagging) {
         $blogTagsById[$tagging['taggable_id']][$tagging['tag_id']] = true;
     }
     $pageTaggings = $migrate->query("SELECT * FROM tagging WHERE taggable_model IN ('aPage')");
     $pageTagsById = array();
     foreach ($pageTaggings as $tagging) {
         $pageTagsById[$tagging['taggable_id']][$tagging['tag_id']] = true;
     }
     foreach ($blogTagsById as $blogId => $tags) {
         if (!isset($blogPagesById[$blogId])) {
             // No virtual page - just a stale tagging
             continue;
         }
         foreach ($tags as $tagId => $dummy) {
             if (!isset($pageTagsById[$blogPagesById[$blogId]][$tagId])) {
                 $migrate->query('INSERT INTO tagging (taggable_model, taggable_id, tag_id) VALUES ("aPage", :taggable_id, :tag_id)', array('taggable_id' => $blogPagesById[$blogId], 'tag_id' => $tagId));
             }
         }
     }
     $migrate->query('UPDATE a_page SET engine = "aBlog" WHERE slug LIKE "@a_blog_search_redirect%"');
     $migrate->query('UPDATE a_page SET engine = "aEvent" WHERE slug LIKE "@a_event_search_redirect%"');
     // Older blog post virtual pages won't have published_at
     $migrate->query('update a_page p inner join a_blog_item bi on bi.page_id = p.id set p.published_at = bi.published_at');
     // Really old events may have full timestamps in start_date and end_date, break them out
     $migrate->query('UPDATE a_blog_item SET start_time = substr(start_date, 12), start_date = substr(start_date, 1, 10) WHERE (length(start_date) > 10) AND start_time IS NULL');
     $migrate->query('ALTER TABLE a_blog_item modify column start_date date;');
     $migrate->query('UPDATE a_blog_item SET end_time = substr(end_date, 12), end_date = substr(end_date, 1, 10) WHERE (length(end_date) > 10) AND end_time IS NULL');
     $migrate->query('ALTER TABLE a_blog_item modify column end_date date;');
     // Migrate old full day events from before we started defining this as a null start and end time
     $migrate->query('UPDATE a_blog_item SET start_time = null, end_time = null WHERE start_time = "00:00:00" AND end_time = "00:00:00"');
     if ($migrate->tableExists('a_blog_category_user')) {
         $oldCategoryUsers = $migrate->query('SELECT * FROM a_blog_category_user');
         $oldCategories = $migrate->query('SELECT * from a_blog_category');
         $newCategories = $migrate->query('SELECT * from a_category');
         $oldByName = array();
         foreach ($oldCategories as $oldCategory) {
             $oldByName[$oldCategory['name']] = $oldCategory['id'];
         }
//.........这里部分代码省略.........
开发者ID:existanze,项目名称:apostropheBlogPlugin,代码行数:101,代码来源:aBlogEvents.class.php

示例4: array

?>
	
<?php 
$page ? $slots = $page->getArea('body') : ($slots = array());
?>

<?php 
// If there are no slots, show some default text
if (!count($slots)) {
    ?>
	<h2><?php 
    echo a_('Error 404 &mdash; The page you are looking for could not be found.');
    ?>
</h2>
	<?php 
    $search = trim(aTools::slugify(str_replace($sf_request->getUriPrefix(), '', $sf_request->getUri()), false, false, ' '));
    ?>
	<h3><?php 
    echo link_to(a_('Try searching for %SEARCH%.', array('%SEARCH%' => $search)), 'a/search?' . http_build_query(array('q' => $search)));
    ?>
</h3>
	<h3><a href="/"><?php 
    echo a_('Go Home.');
    ?>
</a></h3>
<?php 
}
?>

<?php 
// Display some help information to admins so they know they can customize the Error404 page
开发者ID:hashir,项目名称:UoA,代码行数:31,代码来源:error404Success.php

示例5: updateLastSlugComponent

 /**
  * DOCUMENT ME
  * @param mixed $title
  * @return mixed
  */
 public function updateLastSlugComponent($title)
 {
     if ($this->slug === '/') {
         // We never update the home page slug
         return;
     }
     if ($this->getCulture() !== sfConfig::get('sf_default_culture')) {
         // Retitling a page in a culture other than the default does not
         // change the page slug
         return;
     }
     $component = aTools::slugify($title, false);
     $path = $this->slug;
     if (function_exists('mb_strrpos')) {
         $slash = mb_strrpos($path, '/');
         $newPath = mb_substr($path, 0, $slash + 1) . $component;
     } else {
         $slash = strrpos($path, '/');
         $newPath = substr($path, 0, $slash + 1) . $component;
     }
     if ($path === $newPath) {
         return;
     }
     $this->slug = $newPath;
     $this->save();
     Doctrine::getTable('aRedirect')->update($path, $this);
     $children = $this->getChildren();
     foreach ($children as $child) {
         $child->updateParentSlug($path, $newPath);
     }
 }
开发者ID:hashir,项目名称:UoA,代码行数:36,代码来源:PluginaPage.class.php

示例6: findOrAddVideo

 /**
  * Finds or adds a video without the overhead of a proper Doctrine save.
  * @param array $info
  * @return mixed
  */
 protected function findOrAddVideo($info)
 {
     $mediaId = null;
     $slug = null;
     if (!isset($info['title'])) {
         $info['title'] = 'Imported video';
     }
     $slug = aTools::slugify(!empty($info['title']) ? $info['title'] : (!empty($info['service_url']) ? $info['service_url'] : md5($info['embed'])));
     $result = $this->sql->query('SELECT id FROM a_media_item WHERE slug = :slug', array('slug' => $slug));
     if (isset($result[0]['id'])) {
         $mediaId = $result[0]['id'];
     } else {
         $mediaItem = new aMediaItem();
         foreach ($info as $key => $value) {
             if ($key !== 'tags') {
                 $mediaItem[$key] = $value;
             }
         }
         if (empty($mediaItem['title'])) {
             $mediaItem->setTitle($slug);
         } else {
             $mediaItem->setTitle($info['title']);
         }
         $mediaItem->setSlug($slug);
         $mediaItem->setType('video');
         if ($mediaItem->service_url) {
             $service = aMediaTools::getEmbedService($mediaItem->service_url);
             $id = $service->getIdFromUrl($mediaItem->service_url);
             if ($service->supports('thumbnail')) {
                 $filename = $service->getThumbnail($id);
                 if ($filename) {
                     // saveFile can't handle a nonlocal file directly, so
                     // copy to a temporary file first
                     $bad = isset($this->failedMedia[$filename]);
                     if (!$bad) {
                         $tmpFile = aFiles::getTemporaryFilename();
                         try {
                             if (!copy($filename, $tmpFile)) {
                                 throw new sfException(sprintf('Could not copy file: %s', $src));
                             }
                             if (!$mediaItem->saveFile($tmpFile)) {
                                 throw new sfException(sprintf('Could not save file: %s', $src));
                             }
                         } catch (Exception $e) {
                             $this->failedMedia[$filename] = true;
                         }
                         unlink($tmpFile);
                     }
                 }
             }
         }
         $this->sql->fastSaveMediaItem($mediaItem);
         if (count($info['tags'])) {
             $this->sql->fastSaveTags('aMediaItem', $mediaItem->id, $info['tags']);
         }
         $mediaId = $mediaItem->id;
         $mediaItem->free(true);
     }
     return $mediaId;
 }
开发者ID:hashir,项目名称:UoA,代码行数:65,代码来源:aImporter.class.php

示例7: executeSlugify

 /**
  * A REST API to aTools::slugify(), used when suggesting page slugs for new pages.
  * "Can't you just reimplement it in JavaScript?" No.
  * some of the major browsers (*cough* IE) can't manipulate Unicode in regular expressions.
  * Also two implementations mean our code will drift apart and introduce bugs
  * Returns a suitable slug for a new page component (i.e. based on a title).
  * The browser appends this to the slug of the parent page to create its suggestion
  * @param sfWebRequest $request
  */
 public function executeSlugify(sfWebRequest $request)
 {
     $slug = $request->getParameter('slug');
     $this->slug = aTools::slugify($slug, false);
     $this->setLayout(false);
 }
开发者ID:hashir,项目名称:UoA,代码行数:15,代码来源:BaseaActions.class.php

示例8: executeCreate

 public function executeCreate()
 {
     $this->flunkUnless($this->getRequest()->getMethod() == sfRequest::POST);
     $parent = $this->retrievePageForEditingBySlugParameter('parent', 'manage');
     $title = trim($this->getRequestParameter('title'));
     $this->flunkUnless(strlen($title));
     $pathComponent = aTools::slugify($title, false);
     $base = $parent->getSlug();
     if ($base === '/') {
         $base = '';
     }
     $slug = "{$base}/{$pathComponent}";
     $page = new aPage();
     $page->setArchived(!sfConfig::get('app_a_default_on', true));
     $page->setSlug($slug);
     $existingPage = aPageTable::retrieveBySlug($slug);
     if ($existingPage) {
         // TODO: an error in addition to displaying the existing page?
         return $this->redirect($existingPage->getUrl());
     } else {
         $page->getNode()->insertAsFirstChildOf($parent);
         // Figure out what template this new page should use based on
         // the template rules.
         //
         // The default rule assigns default to everything.
         $rule = aRules::select(sfConfig::get('app_a_template_rules', array(array('rule' => '*', 'template' => 'default'))), $slug);
         if (!$rule) {
             $template = 'default';
         } else {
             $template = $rule['template'];
         }
         $page->template = $template;
         // Must save the page BEFORE we call setTitle, which has the side effect of
         // refreshing the page object
         $page->save();
         $page->setTitle(htmlspecialchars($title));
         return $this->redirect($page->getUrl());
     }
 }
开发者ID:quafzi,项目名称:timpany-prototype,代码行数:39,代码来源:BaseaActions.class.php

示例9: uniqueSlugFromTitle

 protected function uniqueSlugFromTitle($title)
 {
     return $this->uniqueifySlug(aTools::slugify(html_entity_decode($title, ENT_COMPAT, 'UTF-8')));
 }
开发者ID:existanze,项目名称:apostropheBlogPlugin,代码行数:4,代码来源:PluginaBlogItem.class.php

示例10: preUpdate

 /**
  * preUpdate function used to do some slugification.
  * @param <type> $event
  */
 public function preUpdate($event)
 {
     if ($this->update) {
         // If the slug was altered by the user we no longer want to attempt to sluggify
         // the title to create the slug
         if (array_key_exists('slug', $this->getModified())) {
             $this['slug_saved'] = true;
         }
         if ($this['slug_saved'] == false && array_key_exists('title', $this->getModified())) {
             // If the slug hasn't been altered slugify the title to create the slug
             $this['slug'] = aTools::slugify($this->_get('title'));
         } else {
             // Otherwise slugify the user entered value.
             $this['slug'] = aTools::slugify($this['slug']);
         }
     }
     $this->Page['view_is_secure'] = $this['status'] == 'published' ? false : true;
     // Check if a blog post or event already has this slug
     $i = 1;
     $slug = $this['slug'];
     while ($this->findConflictingItem()) {
         $this['slug'] = $slug . '-' . $i;
         $i++;
     }
 }
开发者ID:quafzi,项目名称:timpany-prototype,代码行数:29,代码来源:PluginaBlogItem.class.php

示例11: slugify

 /**
  * Generate a unique, safe slug
  */
 public function slugify($slug)
 {
     $slug = aTools::slugify($slug);
     while (count($this->sql->query('select id from a_blog_item where slug = :slug', array('slug' => $slug)))) {
         if (preg_match('/^(.*)-(\\d+)$/', $slug, $matches)) {
             $rest = $matches[1];
             $ordinal = $matches[2];
             $ordinal++;
             $slug = $rest . "-" . $ordinal;
         } else {
             $slug .= "-1";
         }
     }
     return $slug;
 }
开发者ID:hashir,项目名称:UoA,代码行数:18,代码来源:aBlogImporter.class.php

示例12: go

 /**
  * DOCUMENT ME
  */
 public function go()
 {
     $dir_iterator = new RecursiveDirectoryIterator($this->dir);
     $iterator = new RecursiveIteratorIterator($dir_iterator, RecursiveIteratorIterator::SELF_FIRST);
     $count = 0;
     $mimeTypes = aMediaTools::getOption('mime_types');
     // It comes back as a mapping of extensions to types, get the types
     $extensions = array_keys($mimeTypes);
     $mimeTypes = array_values($mimeTypes);
     foreach ($iterator as $sfile) {
         if ($sfile->isFile()) {
             $file = $sfile->getPathname();
             if (preg_match('/(^|\\/)\\./', $file)) {
                 # Silently ignore all dot folders to avoid trouble with svn and friends
                 $this->giveFeedback("info", "Ignoring dotfile", $file);
                 continue;
             }
             $pathinfo = pathinfo($file);
             // basename and filename seem backwards to me, but that's how it is in the PHP docs and
             // sure enough that's how it behaves
             if ($pathinfo['basename'] === 'Thumbs.db') {
                 continue;
             }
             $vfp = new aValidatorFilePersistent(array('mime_types' => $mimeTypes, 'validated_file_class' => 'aValidatedFile', 'required' => false), array('mime_types' => 'The following file types are accepted: ' . implode(', ', $extensions)));
             $guid = aGuid::generate();
             try {
                 $vf = $vfp->clean(array('newfile' => array('tmp_name' => $file, 'name' => $pathinfo['basename']), 'persistid' => $guid));
             } catch (Exception $e) {
                 $this->giveFeedback("warning", "Not supported or corrupt", $file);
                 continue;
             }
             $item = new aMediaItem();
             // Split it up to make tags out of the portion of the path that isn't dir (i.e. the folder structure they used)
             $dir = $this->dir;
             $dir = preg_replace('/\\/$/', '', $dir) . '/';
             $relevant = preg_replace('/^' . preg_quote($dir, '/') . '/', '', $file);
             // TODO: not Microsoft-friendly, might matter in some setting
             $components = preg_split('/\\//', $relevant);
             $tags = array_slice($components, 0, count($components) - 1);
             foreach ($tags as &$tag) {
                 // We don't strictly need to be this harsh, but it's safe and definitely
                 // takes care of some things we definitely can't allow, like periods
                 // (which cause mod_rewrite problems with pretty Symfony URLs).
                 // TODO: clean it up in a nicer way without being UTF8-clueless
                 // (aTools::slugify is UTF8-safe)
                 $tag = aTools::slugify($tag);
             }
             $item->title = aMediaTools::filenameToTitle($pathinfo['basename']);
             $item->setTags($tags);
             if (!strlen($item->title)) {
                 $this->giveFeedback("error", "Files must have a basename", $file);
                 continue;
             }
             // The preSaveImage / save / saveImage dance is necessary because
             // the sluggable behavior doesn't kick in until save and the image file
             // needs a slug based filename.
             if (!$item->preSaveFile($vf)) {
                 $this->giveFeedback("error", "Save failed", $file);
                 continue;
             }
             $item->save();
             if (!$item->saveFile($vf)) {
                 $this->giveFeedback("error", "Save failed", $file);
                 $item->delete();
                 continue;
             }
             unlink($file);
             $count++;
             $this->giveFeedback("completed", $count, $file);
         }
     }
     $this->giveFeedback("total", $count);
 }
开发者ID:hashir,项目名称:UoA,代码行数:76,代码来源:aMediaImporter.class.php

示例13: slugify

 public static function slugify($s, $item)
 {
     return aTools::slugify($s);
 }
开发者ID:existanze,项目名称:apostropheBlogPlugin,代码行数:4,代码来源:aBlogToolkit.class.php

示例14: isset

<?php

// Compatible with sf_escaping_strategy: true
$a_event = isset($a_event) ? $sf_data->getRaw('a_event') : null;
?>

<?php 
use_helper("a");
?>

<?php 
$catClass = "";
foreach ($a_event->getCategories() as $category) {
    $catClass .= " category-" . aTools::slugify($category);
}
?>

<div class="a-blog-item event <?php 
echo $a_event->getTemplate();
echo $catClass != '' ? $catClass : '';
?>
">
  <?php 
if ($a_event->userHasPrivilege('edit')) {
    ?>
	  <ul class="a-ui a-controls a-blog-post-controls">
			<li>
			<?php 
    echo a_button(a_('Edit'), url_for('a_event_admin_edit', $a_event), array('a-btn', 'icon', 'a-edit', 'lite', 'alt', 'no-label'));
    ?>
			</li>
开发者ID:existanze,项目名称:apostropheBlogPlugin,代码行数:31,代码来源:_post.php

示例15: updateObject

 /**
  * DOCUMENT ME
  * @param mixed $values
  */
 public function updateObject($values = null)
 {
     if (is_null($values)) {
         $values = $this->getValues();
     }
     $oldSlug = $this->getObject()->slug;
     if (!isset($values['slug']) && isset($values['realtitle']) && $oldSlug !== '/') {
         // If they can manually edit the title but not the slug, we need to autogenerate and
         // autoupdate the slug so they have reasonable options to avoid collisions
         $oldSlug = $this->getObject()->slug;
         if (!strlen($oldSlug)) {
             // New page, provide a starter slug to replace
             $oldSlug = $this->parent->slug . '/';
         }
         $newSlug = preg_replace('|/[^/]*$|', '/' . aTools::slugify($values['realtitle'], false, false), $oldSlug);
         $suffix = '';
         $n = 0;
         while (true) {
             $values['slug'] = $newSlug . $suffix;
             if ($values['slug'] === $oldSlug) {
                 break;
             }
             $existing = Doctrine::getTable('aPage')->findOneBySlug($values['slug']);
             if (!$existing) {
                 break;
             }
             $suffix = '-' . $n;
             $n++;
         }
         $this->getObject()->slug = $values['slug'];
     }
     // Slashes break routes in most server configs. Do NOT force case of tags.
     $values['tags'] = str_replace('/', '-', isset($values['tags']) ? $values['tags'] : '');
     $object = parent::updateObject($values);
     // Check for cascading operations
     if ($this->getValue('cascade_archived')) {
         $q = Doctrine::getTable('aPage')->createQuery()->update()->where('lft > ? and rgt < ?', array($object->getLft(), $object->getRgt()));
         if ($this->getValue('cascade_archived')) {
             $q->set('archived', '?', $object->getArchived());
         }
         $q->execute();
     }
     if (isset($values['joinedtemplate'])) {
         $template = $values['joinedtemplate'];
         // $templates = aTools::getTemplates();
         list($engine, $etemplate) = preg_split('/:/', $template);
         if ($engine === 'a') {
             $object->engine = null;
         } else {
             $object->engine = $engine;
         }
         $object->template = $etemplate;
     }
     // On manual change of slug, set up a redirect from the old slug,
     // and notify child pages so they can update their slugs if they are
     // not already deliberately different
     if ($object->slug !== $oldSlug) {
         Doctrine::getTable('aRedirect')->update($oldSlug, $object);
         $children = $object->getChildren();
         foreach ($children as $child) {
             $child->updateParentSlug($oldSlug, $object->slug);
         }
     }
     if (isset($object->engine) && !strlen($object->engine)) {
         // Store it as null for plain ol' executeShow page templating
         $object->engine = null;
     }
     // A new page must be added as a child of its parent
     if ($this->parent) {
         $this->getObject()->getNode()->insertAsFirstChildOf($this->parent);
     }
     $jvalues = json_decode($this->getValue('view_groups'), true);
     // Most custom permissions are saved in separate methods called from save()
     // after the object exists. However the "Editors + Guests" group is a special
     // case which really maps to everyone who has the 'view_locked' permission, so
     // we have to scan for it in the list of groups
     foreach ($jvalues as $value) {
         if ($value['id'] === 'editors_and_guests') {
             // Editors + Guests special case
             $object->view_guest = $value['selected'] && $value['selected'] !== 'remove';
         }
     }
     // Check for cascading operations
     if ($this->getValue('cascade_archived')) {
         $q = Doctrine::getTable('aPage')->createQuery()->update()->where('lft > ? and rgt < ?', array($object->getLft(), $object->getRgt()));
         $q->set('archived', '?', $object->getArchived());
         $q->execute();
     }
     if ($values['view_options'] === 'public') {
         $object->view_admin_lock = false;
         $object->view_is_secure = false;
     } elseif ($values['view_options'] === 'login') {
         $object->view_admin_lock = false;
         $object->view_is_secure = true;
     } elseif ($values['view_options'] === 'admin') {
         $object->view_admin_lock = true;
//.........这里部分代码省略.........
开发者ID:hashir,项目名称:UoA,代码行数:101,代码来源:BaseaPageSettingsForm.class.php


注:本文中的aTools::slugify方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。