ここの情報は古いです。ご理解頂いた上でお取り扱いください。

source: OpenPNE3/plugins/opBlogPlugin/trunk/lib/form/MemberConfigForm/MemberConfigBlogUrlForm.class.php @ 10553

Last change on this file since 10553 was 10553, checked in by nagasawa, 11 years ago

#3465:fixed setting of errorSchema of an error message was wrong

File size: 1.2 KB
Line 
1<?php
2
3/**
4 * This file is part of the OpenPNE package.
5 * (c) OpenPNE Project (http://www.openpne.jp/)
6 *
7 * For the full copyright and license information, please view the LICENSE
8 * file and the NOTICE file that were distributed with this source code.
9 */
10
11/**
12 * MemberConfigBlogUrlForm form.
13 *
14 * @package    OpenPNE
15 * @subpackage form
16 * @author     Masato Nagasawa <nagasawa@tejimaya.net>
17 */
18class MemberConfigBlogUrlForm extends MemberConfigForm
19{
20  protected $category = 'blogUrl';
21
22  public function setMemberConfigWidget($name)
23  {
24    $result = parent::setMemberConfigWidget($name);
25
26    if ($name === 'blog_url')
27    {
28      $this->widgetSchema['blog_url']->setAttributes(array('size' => 69));
29      $this->mergePostValidator(new sfValidatorCallback(array(
30        'callback'  => array($this, 'validate'),
31      )));
32    }
33
34    return $result;
35  }
36
37  public function validate($validator, $value)
38  {
39    if ($value['blog_url'] !== "")
40    {
41      $root = BlogPeer::getXmlByUrl($value['blog_url']);
42      if (!BlogPeer::getFeedType($root))
43      {
44        $error = new sfValidatorError($validator, 'URL is invalid.');
45        throw new sfValidatorErrorSchema($validator, array('blog_url' => $error));
46      }
47    }
48    return $value;
49  }
50}
Note: See TracBrowser for help on using the repository browser.