Completed
Push — master ( 45de7b...71112b )
by Rasmus
04:48
created

ContentController::contentForm()   D

Complexity

Conditions 14
Paths 4

Size

Total Lines 125
Code Lines 92

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 197.5152

Importance

Changes 0
Metric Value
dl 0
loc 125
ccs 2
cts 92
cp 0.0217
rs 4.9516
c 0
b 0
f 0
cc 14
eloc 92
nc 4
nop 2
crap 197.5152

How to fix   Long Method    Complexity   

Long Method

Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.

For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.

Commonly applied refactorings include:

1
<?php
2
namespace Chp\TextContent;
3
4
/**
5
 * Text content controller
6
 * Made by Rasmus Berg (c) 2014-2017
7
 *
8
 * @Property  Object  $this->di         Anax-MVC class handler
9
 * @Property  Object  $this->request    Anax-MVC $_POST, $_GET and $_SERVER handler class
10
 * @Property  Object  $this->response   Anax-MVC Php Header class
11
 * @Property  Object  $this->url        Anax-MVC url-handler class
12
 * @Property  Object  $this->theme      Anax-MVC theme-handler class
13
 * @Property  Object  $this->views      Anax-MVC views-handler class
14
 * @Property  Object  $this->textFilter Anax-MVC textformat-handler class
15
 * @Property  Object  $this->db         PDO database class
16
 */
17
class ContentController implements \Anax\DI\IInjectionAware
18
{
19
  use \Anax\DI\TInjectable;
20
  
21
  /**
22
	 * Properties
23
	 */
24
  private $content = null;
25
  private $limitListPerPage = null;       // Limit contents on list page
26
  private $minimumLength    = 3;          // Minimum length on text-fields (ex. ingress, title etc)
27
  private $types 		        = [		        // Content types
28
		'blog-post'   => ['url' => 'blog/read/',  'field' => 'slug', 	'perfix' => '', 	'title' => 'Blog'],
29
		'page'        => ['url' => 'page/page/', 	'field' => 'url', 	'perfix' => '', 	'title' => 'Page']
30
	];
31
  private $filters = array('bbcode','clickable','markdown', 'nl2br', 'shortcode');
32
  private $urlPrefix = "content.php/";
33
  
34
  /**
35
   * Initialize the controller
36
   *
37
   * @Return    Void
38
   */
39 9
  public function initialize(){
40 9
    $this->content = new \Chp\TextContent\Content();
41 9
    $this->content->setDI($this->di);
1 ignored issue
show
Bug introduced by
It seems like $this->di can also be of type array or null; however, Anax\DI\IInjectionAware::setDI() does only seem to accept object<Anax\DI\class>, maybe add an additional type check?

If a method or function can return multiple different values and unless you are sure that you only can receive a single value in this context, we recommend to add an additional type check:

/**
 * @return array|string
 */
function returnsDifferentValues($x) {
    if ($x) {
        return 'foo';
    }

    return array();
}

$x = returnsDifferentValues($y);
if (is_array($x)) {
    // $x is an array.
}

If this a common case that PHP Analyzer should handle natively, please let us know by opening an issue.

Loading history...
42 9
  }
43
  
44
  /**
45
	 *  Index content - use listAction 
46
   *
47
	 * @Returns		Void
48
	 */
49
	public function indexAction(){
50
    $this->listAction();
51
  }
52
  
53
  /**
54
   * Setup content (If it allready exist it will restore database to begining)
55
   *
56
   * @Return    Void
57
   */
58
  public function setupAction(){
59
    $toDo   = "Restore or setup";
60
    $toWhat = "content database tables";
61
    $title  = "{$toDo} {$toWhat}";
62
    $form   = $this->confirmForm($this->url->create($this->urlPrefix . 'content/'));
1 ignored issue
show
Documentation introduced by
The property url does not exist on object<Chp\TextContent\ContentController>. Since you implemented __get, maybe consider adding a @property annotation.

Since your code implements the magic getter _get, this function will be called for any read access on an undefined variable. You can add the @property annotation to your class or interface to document the existence of this variable.

<?php

/**
 * @property int $x
 * @property int $y
 * @property string $text
 */
class MyLabel
{
    private $properties;

    private $allowedProperties = array('x', 'y', 'text');

    public function __get($name)
    {
        if (isset($properties[$name]) && in_array($name, $this->allowedProperties)) {
            return $properties[$name];
        } else {
            return null;
        }
    }

    public function __set($name, $value)
    {
        if (in_array($name, $this->allowedProperties)) {
            $properties[$name] = $value;
        } else {
            throw new \LogicException("Property $name is not defined.");
        }
    }

}

If the property has read access only, you can use the @property-read annotation instead.

Of course, you may also just have mistyped another name, in which case you should fix the error.

See also the PhpDoc documentation for @property.

Loading history...
63
    $status = $form->check();
64
 
65
    if($status === true){
66
    
67
      $this->db->dropTableIfExists('content')->execute();
0 ignored issues
show
Documentation introduced by
The property db does not exist on object<Chp\TextContent\ContentController>. Since you implemented __get, maybe consider adding a @property annotation.

Since your code implements the magic getter _get, this function will be called for any read access on an undefined variable. You can add the @property annotation to your class or interface to document the existence of this variable.

<?php

/**
 * @property int $x
 * @property int $y
 * @property string $text
 */
class MyLabel
{
    private $properties;

    private $allowedProperties = array('x', 'y', 'text');

    public function __get($name)
    {
        if (isset($properties[$name]) && in_array($name, $this->allowedProperties)) {
            return $properties[$name];
        } else {
            return null;
        }
    }

    public function __set($name, $value)
    {
        if (in_array($name, $this->allowedProperties)) {
            $properties[$name] = $value;
        } else {
            throw new \LogicException("Property $name is not defined.");
        }
    }

}

If the property has read access only, you can use the @property-read annotation instead.

Of course, you may also just have mistyped another name, in which case you should fix the error.

See also the PhpDoc documentation for @property.

Loading history...
68
69
      $this->db->createTable(
1 ignored issue
show
Documentation introduced by
The property db does not exist on object<Chp\TextContent\ContentController>. Since you implemented __get, maybe consider adding a @property annotation.

Since your code implements the magic getter _get, this function will be called for any read access on an undefined variable. You can add the @property annotation to your class or interface to document the existence of this variable.

<?php

/**
 * @property int $x
 * @property int $y
 * @property string $text
 */
class MyLabel
{
    private $properties;

    private $allowedProperties = array('x', 'y', 'text');

    public function __get($name)
    {
        if (isset($properties[$name]) && in_array($name, $this->allowedProperties)) {
            return $properties[$name];
        } else {
            return null;
        }
    }

    public function __set($name, $value)
    {
        if (in_array($name, $this->allowedProperties)) {
            $properties[$name] = $value;
        } else {
            throw new \LogicException("Property $name is not defined.");
        }
    }

}

If the property has read access only, you can use the @property-read annotation instead.

Of course, you may also just have mistyped another name, in which case you should fix the error.

See also the PhpDoc documentation for @property.

Loading history...
70
        'content',
71
        [
72
          'id'        => ['integer', 'primary key', 'not null', 'auto_increment'],
73
          'slug'      => ['char(80)'],
74
          'url'       => ['char(80)'],
75
          'type'      => ['char(80)'],
76
          'title'     => ['varchar(80)'],
77
          'ingress'   => ['text'],
78
          'text'      => ['text'],
79
          'filters'   => ['char(80)'],
80
          'author'    => ['integer', 'not null'],
81
          'published' => ['datetime'],
82
          'created'   => ['datetime'],
83
          'updated'   => ['datetime'],
84
          'deleted'   => ['datetime']
85
        ]
86
      )->execute();
87
      
88
      $this->db->insert(
1 ignored issue
show
Documentation introduced by
The property db does not exist on object<Chp\TextContent\ContentController>. Since you implemented __get, maybe consider adding a @property annotation.

Since your code implements the magic getter _get, this function will be called for any read access on an undefined variable. You can add the @property annotation to your class or interface to document the existence of this variable.

<?php

/**
 * @property int $x
 * @property int $y
 * @property string $text
 */
class MyLabel
{
    private $properties;

    private $allowedProperties = array('x', 'y', 'text');

    public function __get($name)
    {
        if (isset($properties[$name]) && in_array($name, $this->allowedProperties)) {
            return $properties[$name];
        } else {
            return null;
        }
    }

    public function __set($name, $value)
    {
        if (in_array($name, $this->allowedProperties)) {
            $properties[$name] = $value;
        } else {
            throw new \LogicException("Property $name is not defined.");
        }
    }

}

If the property has read access only, you can use the @property-read annotation instead.

Of course, you may also just have mistyped another name, in which case you should fix the error.

See also the PhpDoc documentation for @property.

Loading history...
89
        'content',
90
        ['slug', 'url', 'type', 'title', 'ingress', 'text', 'filters', 'author', 'published', 'created']
91
      );
92
93
      $now = date('Y-m-d H:i:s');
94
95
      $this->db->execute([
1 ignored issue
show
Documentation introduced by
The property db does not exist on object<Chp\TextContent\ContentController>. Since you implemented __get, maybe consider adding a @property annotation.

Since your code implements the magic getter _get, this function will be called for any read access on an undefined variable. You can add the @property annotation to your class or interface to document the existence of this variable.

<?php

/**
 * @property int $x
 * @property int $y
 * @property string $text
 */
class MyLabel
{
    private $properties;

    private $allowedProperties = array('x', 'y', 'text');

    public function __get($name)
    {
        if (isset($properties[$name]) && in_array($name, $this->allowedProperties)) {
            return $properties[$name];
        } else {
            return null;
        }
    }

    public function __set($name, $value)
    {
        if (in_array($name, $this->allowedProperties)) {
            $properties[$name] = $value;
        } else {
            throw new \LogicException("Property $name is not defined.");
        }
    }

}

If the property has read access only, you can use the @property-read annotation instead.

Of course, you may also just have mistyped another name, in which case you should fix the error.

See also the PhpDoc documentation for @property.

Loading history...
96
        'welcome_to_your_new_blog',
97
        NULL,
98
        'blog-post',
99
        'Welcome to your new blog',
100
        'This is example-blogg to show your new blog system!',
101
        'You can start blog by visit [url=' . $this->url->create($this->urlPrefix . "content/add/") . ']Add content[/url]',
0 ignored issues
show
Documentation introduced by
The property url does not exist on object<Chp\TextContent\ContentController>. Since you implemented __get, maybe consider adding a @property annotation.

Since your code implements the magic getter _get, this function will be called for any read access on an undefined variable. You can add the @property annotation to your class or interface to document the existence of this variable.

<?php

/**
 * @property int $x
 * @property int $y
 * @property string $text
 */
class MyLabel
{
    private $properties;

    private $allowedProperties = array('x', 'y', 'text');

    public function __get($name)
    {
        if (isset($properties[$name]) && in_array($name, $this->allowedProperties)) {
            return $properties[$name];
        } else {
            return null;
        }
    }

    public function __set($name, $value)
    {
        if (in_array($name, $this->allowedProperties)) {
            $properties[$name] = $value;
        } else {
            throw new \LogicException("Property $name is not defined.");
        }
    }

}

If the property has read access only, you can use the @property-read annotation instead.

Of course, you may also just have mistyped another name, in which case you should fix the error.

See also the PhpDoc documentation for @property.

Loading history...
102
        'bbcode',
103
        3,
104
        $now,
105
        $now
106
      ]);
107
      
108
      $this->db->execute([
0 ignored issues
show
Documentation introduced by
The property db does not exist on object<Chp\TextContent\ContentController>. Since you implemented __get, maybe consider adding a @property annotation.

Since your code implements the magic getter _get, this function will be called for any read access on an undefined variable. You can add the @property annotation to your class or interface to document the existence of this variable.

<?php

/**
 * @property int $x
 * @property int $y
 * @property string $text
 */
class MyLabel
{
    private $properties;

    private $allowedProperties = array('x', 'y', 'text');

    public function __get($name)
    {
        if (isset($properties[$name]) && in_array($name, $this->allowedProperties)) {
            return $properties[$name];
        } else {
            return null;
        }
    }

    public function __set($name, $value)
    {
        if (in_array($name, $this->allowedProperties)) {
            $properties[$name] = $value;
        } else {
            throw new \LogicException("Property $name is not defined.");
        }
    }

}

If the property has read access only, you can use the @property-read annotation instead.

Of course, you may also just have mistyped another name, in which case you should fix the error.

See also the PhpDoc documentation for @property.

Loading history...
109
        'welcome_to_your_new_page',
110
        'example-page',
111
        'page',
112
        'Welcome to your new page',
113
        'This is example-page to show your new page system!',
114
        'You can start makeing pages by visit [url=' . $this->url->create($this->urlPrefix . "content/add/") . ']Add content[/url]',
1 ignored issue
show
Documentation introduced by
The property url does not exist on object<Chp\TextContent\ContentController>. Since you implemented __get, maybe consider adding a @property annotation.

Since your code implements the magic getter _get, this function will be called for any read access on an undefined variable. You can add the @property annotation to your class or interface to document the existence of this variable.

<?php

/**
 * @property int $x
 * @property int $y
 * @property string $text
 */
class MyLabel
{
    private $properties;

    private $allowedProperties = array('x', 'y', 'text');

    public function __get($name)
    {
        if (isset($properties[$name]) && in_array($name, $this->allowedProperties)) {
            return $properties[$name];
        } else {
            return null;
        }
    }

    public function __set($name, $value)
    {
        if (in_array($name, $this->allowedProperties)) {
            $properties[$name] = $value;
        } else {
            throw new \LogicException("Property $name is not defined.");
        }
    }

}

If the property has read access only, you can use the @property-read annotation instead.

Of course, you may also just have mistyped another name, in which case you should fix the error.

See also the PhpDoc documentation for @property.

Loading history...
115
        'bbcode',
116
        3,
117
        $now,
118
        $now
119
      ]);
120
      
121
      $this->db->dropTableIfExists('content_tags')->execute();
1 ignored issue
show
Documentation introduced by
The property db does not exist on object<Chp\TextContent\ContentController>. Since you implemented __get, maybe consider adding a @property annotation.

Since your code implements the magic getter _get, this function will be called for any read access on an undefined variable. You can add the @property annotation to your class or interface to document the existence of this variable.

<?php

/**
 * @property int $x
 * @property int $y
 * @property string $text
 */
class MyLabel
{
    private $properties;

    private $allowedProperties = array('x', 'y', 'text');

    public function __get($name)
    {
        if (isset($properties[$name]) && in_array($name, $this->allowedProperties)) {
            return $properties[$name];
        } else {
            return null;
        }
    }

    public function __set($name, $value)
    {
        if (in_array($name, $this->allowedProperties)) {
            $properties[$name] = $value;
        } else {
            throw new \LogicException("Property $name is not defined.");
        }
    }

}

If the property has read access only, you can use the @property-read annotation instead.

Of course, you may also just have mistyped another name, in which case you should fix the error.

See also the PhpDoc documentation for @property.

Loading history...
122
      
123
      $this->db->createTable(
1 ignored issue
show
Documentation introduced by
The property db does not exist on object<Chp\TextContent\ContentController>. Since you implemented __get, maybe consider adding a @property annotation.

Since your code implements the magic getter _get, this function will be called for any read access on an undefined variable. You can add the @property annotation to your class or interface to document the existence of this variable.

<?php

/**
 * @property int $x
 * @property int $y
 * @property string $text
 */
class MyLabel
{
    private $properties;

    private $allowedProperties = array('x', 'y', 'text');

    public function __get($name)
    {
        if (isset($properties[$name]) && in_array($name, $this->allowedProperties)) {
            return $properties[$name];
        } else {
            return null;
        }
    }

    public function __set($name, $value)
    {
        if (in_array($name, $this->allowedProperties)) {
            $properties[$name] = $value;
        } else {
            throw new \LogicException("Property $name is not defined.");
        }
    }

}

If the property has read access only, you can use the @property-read annotation instead.

Of course, you may also just have mistyped another name, in which case you should fix the error.

See also the PhpDoc documentation for @property.

Loading history...
124
        'content_tags',
125
        [
126
          'idContent' => ['integer', 'not null'],
127
          'tag'       => ['varchar(150)', 'not null'],
128
          'slug'      => ['varchar(150)', 'not null']
129
        ]
130
      )->execute();
131
      
132
      $this->db->insert(
0 ignored issues
show
Documentation introduced by
The property db does not exist on object<Chp\TextContent\ContentController>. Since you implemented __get, maybe consider adding a @property annotation.

Since your code implements the magic getter _get, this function will be called for any read access on an undefined variable. You can add the @property annotation to your class or interface to document the existence of this variable.

<?php

/**
 * @property int $x
 * @property int $y
 * @property string $text
 */
class MyLabel
{
    private $properties;

    private $allowedProperties = array('x', 'y', 'text');

    public function __get($name)
    {
        if (isset($properties[$name]) && in_array($name, $this->allowedProperties)) {
            return $properties[$name];
        } else {
            return null;
        }
    }

    public function __set($name, $value)
    {
        if (in_array($name, $this->allowedProperties)) {
            $properties[$name] = $value;
        } else {
            throw new \LogicException("Property $name is not defined.");
        }
    }

}

If the property has read access only, you can use the @property-read annotation instead.

Of course, you may also just have mistyped another name, in which case you should fix the error.

See also the PhpDoc documentation for @property.

Loading history...
133
        'content_tags',
134
        ['idContent', 'tag', 'slug']
135
      );
136
      
137
      $this->db->execute([
0 ignored issues
show
Documentation introduced by
The property db does not exist on object<Chp\TextContent\ContentController>. Since you implemented __get, maybe consider adding a @property annotation.

Since your code implements the magic getter _get, this function will be called for any read access on an undefined variable. You can add the @property annotation to your class or interface to document the existence of this variable.

<?php

/**
 * @property int $x
 * @property int $y
 * @property string $text
 */
class MyLabel
{
    private $properties;

    private $allowedProperties = array('x', 'y', 'text');

    public function __get($name)
    {
        if (isset($properties[$name]) && in_array($name, $this->allowedProperties)) {
            return $properties[$name];
        } else {
            return null;
        }
    }

    public function __set($name, $value)
    {
        if (in_array($name, $this->allowedProperties)) {
            $properties[$name] = $value;
        } else {
            throw new \LogicException("Property $name is not defined.");
        }
    }

}

If the property has read access only, you can use the @property-read annotation instead.

Of course, you may also just have mistyped another name, in which case you should fix the error.

See also the PhpDoc documentation for @property.

Loading history...
138
        1,
139
        'New blog',
140
        'new_blog'
141
      ]);
142
143
      $this->db->execute([
0 ignored issues
show
Documentation introduced by
The property db does not exist on object<Chp\TextContent\ContentController>. Since you implemented __get, maybe consider adding a @property annotation.

Since your code implements the magic getter _get, this function will be called for any read access on an undefined variable. You can add the @property annotation to your class or interface to document the existence of this variable.

<?php

/**
 * @property int $x
 * @property int $y
 * @property string $text
 */
class MyLabel
{
    private $properties;

    private $allowedProperties = array('x', 'y', 'text');

    public function __get($name)
    {
        if (isset($properties[$name]) && in_array($name, $this->allowedProperties)) {
            return $properties[$name];
        } else {
            return null;
        }
    }

    public function __set($name, $value)
    {
        if (in_array($name, $this->allowedProperties)) {
            $properties[$name] = $value;
        } else {
            throw new \LogicException("Property $name is not defined.");
        }
    }

}

If the property has read access only, you can use the @property-read annotation instead.

Of course, you may also just have mistyped another name, in which case you should fix the error.

See also the PhpDoc documentation for @property.

Loading history...
144
        1,
145
        'Blog information',
146
        'blog_information'
147
      ]);
148
      
149
      $this->views->add('text-content/action-finish', [
0 ignored issues
show
Documentation introduced by
The property views does not exist on object<Chp\TextContent\ContentController>. Since you implemented __get, maybe consider adding a @property annotation.

Since your code implements the magic getter _get, this function will be called for any read access on an undefined variable. You can add the @property annotation to your class or interface to document the existence of this variable.

<?php

/**
 * @property int $x
 * @property int $y
 * @property string $text
 */
class MyLabel
{
    private $properties;

    private $allowedProperties = array('x', 'y', 'text');

    public function __get($name)
    {
        if (isset($properties[$name]) && in_array($name, $this->allowedProperties)) {
            return $properties[$name];
        } else {
            return null;
        }
    }

    public function __set($name, $value)
    {
        if (in_array($name, $this->allowedProperties)) {
            $properties[$name] = $value;
        } else {
            throw new \LogicException("Property $name is not defined.");
        }
    }

}

If the property has read access only, you can use the @property-read annotation instead.

Of course, you may also just have mistyped another name, in which case you should fix the error.

See also the PhpDoc documentation for @property.

Loading history...
150
          'title'   => $title,
151
          'msg'     => "Content and content tags database tables " . strtolower($toDo). " was successful!"
152
      ], 'main');
153
      
154
    }
155
    else{      
156
      $this->views->add('text-content/action', [
0 ignored issues
show
Documentation introduced by
The property views does not exist on object<Chp\TextContent\ContentController>. Since you implemented __get, maybe consider adding a @property annotation.

Since your code implements the magic getter _get, this function will be called for any read access on an undefined variable. You can add the @property annotation to your class or interface to document the existence of this variable.

<?php

/**
 * @property int $x
 * @property int $y
 * @property string $text
 */
class MyLabel
{
    private $properties;

    private $allowedProperties = array('x', 'y', 'text');

    public function __get($name)
    {
        if (isset($properties[$name]) && in_array($name, $this->allowedProperties)) {
            return $properties[$name];
        } else {
            return null;
        }
    }

    public function __set($name, $value)
    {
        if (in_array($name, $this->allowedProperties)) {
            $properties[$name] = $value;
        } else {
            throw new \LogicException("Property $name is not defined.");
        }
    }

}

If the property has read access only, you can use the @property-read annotation instead.

Of course, you may also just have mistyped another name, in which case you should fix the error.

See also the PhpDoc documentation for @property.

Loading history...
157
          'title'   => $title,
158
          'toDo'    => strtolower($toDo),
159
          'toWhat'  => $toWhat,
160
          'form'    => $form->getHTML(['novalidate' => true])
161
      ], 'main');
162
    }
163
    
164
    $this->theme->setTitle($title);
0 ignored issues
show
Documentation introduced by
The property theme does not exist on object<Chp\TextContent\ContentController>. Since you implemented __get, maybe consider adding a @property annotation.

Since your code implements the magic getter _get, this function will be called for any read access on an undefined variable. You can add the @property annotation to your class or interface to document the existence of this variable.

<?php

/**
 * @property int $x
 * @property int $y
 * @property string $text
 */
class MyLabel
{
    private $properties;

    private $allowedProperties = array('x', 'y', 'text');

    public function __get($name)
    {
        if (isset($properties[$name]) && in_array($name, $this->allowedProperties)) {
            return $properties[$name];
        } else {
            return null;
        }
    }

    public function __set($name, $value)
    {
        if (in_array($name, $this->allowedProperties)) {
            $properties[$name] = $value;
        } else {
            throw new \LogicException("Property $name is not defined.");
        }
    }

}

If the property has read access only, you can use the @property-read annotation instead.

Of course, you may also just have mistyped another name, in which case you should fix the error.

See also the PhpDoc documentation for @property.

Loading history...
165
  }
166
  
167
  /**
168
	 *  List content (by type)
169
   *
170
	 * @Param     String    $type	  Type to list
171
   * @Param     Integer   $page   Page that paging is on
172
	 * @Return		Void
173
	 */
174
	public function listAction($type = null, $published = false, $page = null){
175
    $type      = ($this->checkType($type)) ? $type : null;
176
    $title     = "All Content {$type} listed";
177
    $published = boolval($published);
178
179
    $form   = $this->listForm($type, $published);
180
    $form->check();
181
    
182
    if(!is_null($type))
183
      $contents = $this->content->getAllContentOfType($type, $page, $this->limitListPerPage, $published);
184
    else
185
      $contents = $this->content->getAllContent($page, $this->limitListPerPage, $published);
186
    $contents = $this->prepareListContent($contents);
0 ignored issues
show
Documentation introduced by
$contents is of type object, but the function expects a array.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
187
    
188
    $this->theme->setTitle($title);
0 ignored issues
show
Documentation introduced by
The property theme does not exist on object<Chp\TextContent\ContentController>. Since you implemented __get, maybe consider adding a @property annotation.

Since your code implements the magic getter _get, this function will be called for any read access on an undefined variable. You can add the @property annotation to your class or interface to document the existence of this variable.

<?php

/**
 * @property int $x
 * @property int $y
 * @property string $text
 */
class MyLabel
{
    private $properties;

    private $allowedProperties = array('x', 'y', 'text');

    public function __get($name)
    {
        if (isset($properties[$name]) && in_array($name, $this->allowedProperties)) {
            return $properties[$name];
        } else {
            return null;
        }
    }

    public function __set($name, $value)
    {
        if (in_array($name, $this->allowedProperties)) {
            $properties[$name] = $value;
        } else {
            throw new \LogicException("Property $name is not defined.");
        }
    }

}

If the property has read access only, you can use the @property-read annotation instead.

Of course, you may also just have mistyped another name, in which case you should fix the error.

See also the PhpDoc documentation for @property.

Loading history...
189
    $this->views->add('text-content/list', 
0 ignored issues
show
Documentation introduced by
The property views does not exist on object<Chp\TextContent\ContentController>. Since you implemented __get, maybe consider adding a @property annotation.

Since your code implements the magic getter _get, this function will be called for any read access on an undefined variable. You can add the @property annotation to your class or interface to document the existence of this variable.

<?php

/**
 * @property int $x
 * @property int $y
 * @property string $text
 */
class MyLabel
{
    private $properties;

    private $allowedProperties = array('x', 'y', 'text');

    public function __get($name)
    {
        if (isset($properties[$name]) && in_array($name, $this->allowedProperties)) {
            return $properties[$name];
        } else {
            return null;
        }
    }

    public function __set($name, $value)
    {
        if (in_array($name, $this->allowedProperties)) {
            $properties[$name] = $value;
        } else {
            throw new \LogicException("Property $name is not defined.");
        }
    }

}

If the property has read access only, you can use the @property-read annotation instead.

Of course, you may also just have mistyped another name, in which case you should fix the error.

See also the PhpDoc documentation for @property.

Loading history...
190
      [
191
        'title'     => $title,
192
        'form'      => $form->getHTML(array('novalidate' => true)),
193
        'contents' 	=> $contents,
194
        'addUrl'	  => $this->url->create($this->urlPrefix . 'content/add/'),
0 ignored issues
show
Documentation introduced by
The property url does not exist on object<Chp\TextContent\ContentController>. Since you implemented __get, maybe consider adding a @property annotation.

Since your code implements the magic getter _get, this function will be called for any read access on an undefined variable. You can add the @property annotation to your class or interface to document the existence of this variable.

<?php

/**
 * @property int $x
 * @property int $y
 * @property string $text
 */
class MyLabel
{
    private $properties;

    private $allowedProperties = array('x', 'y', 'text');

    public function __get($name)
    {
        if (isset($properties[$name]) && in_array($name, $this->allowedProperties)) {
            return $properties[$name];
        } else {
            return null;
        }
    }

    public function __set($name, $value)
    {
        if (in_array($name, $this->allowedProperties)) {
            $properties[$name] = $value;
        } else {
            throw new \LogicException("Property $name is not defined.");
        }
    }

}

If the property has read access only, you can use the @property-read annotation instead.

Of course, you may also just have mistyped another name, in which case you should fix the error.

See also the PhpDoc documentation for @property.

Loading history...
195
        'setupUrl'  => $this->url->create($this->urlPrefix . 'content/setup/')
0 ignored issues
show
Documentation introduced by
The property url does not exist on object<Chp\TextContent\ContentController>. Since you implemented __get, maybe consider adding a @property annotation.

Since your code implements the magic getter _get, this function will be called for any read access on an undefined variable. You can add the @property annotation to your class or interface to document the existence of this variable.

<?php

/**
 * @property int $x
 * @property int $y
 * @property string $text
 */
class MyLabel
{
    private $properties;

    private $allowedProperties = array('x', 'y', 'text');

    public function __get($name)
    {
        if (isset($properties[$name]) && in_array($name, $this->allowedProperties)) {
            return $properties[$name];
        } else {
            return null;
        }
    }

    public function __set($name, $value)
    {
        if (in_array($name, $this->allowedProperties)) {
            $properties[$name] = $value;
        } else {
            throw new \LogicException("Property $name is not defined.");
        }
    }

}

If the property has read access only, you can use the @property-read annotation instead.

Of course, you may also just have mistyped another name, in which case you should fix the error.

See also the PhpDoc documentation for @property.

Loading history...
196
      ]
197
    );
198
199
  }
200
  
201
  /**
202
   * Add content to database
203
   *
204
   * @Return    Void
205
   */
206
  public function addAction(){
207
    $action = "Add";
208
    $title = "{$action} content";
209
    
210
    $form = $this->contentForm($action);
211
    $form->check();
212
    
213
    $this->theme->setTitle($title);
0 ignored issues
show
Documentation introduced by
The property theme does not exist on object<Chp\TextContent\ContentController>. Since you implemented __get, maybe consider adding a @property annotation.

Since your code implements the magic getter _get, this function will be called for any read access on an undefined variable. You can add the @property annotation to your class or interface to document the existence of this variable.

<?php

/**
 * @property int $x
 * @property int $y
 * @property string $text
 */
class MyLabel
{
    private $properties;

    private $allowedProperties = array('x', 'y', 'text');

    public function __get($name)
    {
        if (isset($properties[$name]) && in_array($name, $this->allowedProperties)) {
            return $properties[$name];
        } else {
            return null;
        }
    }

    public function __set($name, $value)
    {
        if (in_array($name, $this->allowedProperties)) {
            $properties[$name] = $value;
        } else {
            throw new \LogicException("Property $name is not defined.");
        }
    }

}

If the property has read access only, you can use the @property-read annotation instead.

Of course, you may also just have mistyped another name, in which case you should fix the error.

See also the PhpDoc documentation for @property.

Loading history...
214
    $this->views->add('text-content/post', 
0 ignored issues
show
Documentation introduced by
The property views does not exist on object<Chp\TextContent\ContentController>. Since you implemented __get, maybe consider adding a @property annotation.

Since your code implements the magic getter _get, this function will be called for any read access on an undefined variable. You can add the @property annotation to your class or interface to document the existence of this variable.

<?php

/**
 * @property int $x
 * @property int $y
 * @property string $text
 */
class MyLabel
{
    private $properties;

    private $allowedProperties = array('x', 'y', 'text');

    public function __get($name)
    {
        if (isset($properties[$name]) && in_array($name, $this->allowedProperties)) {
            return $properties[$name];
        } else {
            return null;
        }
    }

    public function __set($name, $value)
    {
        if (in_array($name, $this->allowedProperties)) {
            $properties[$name] = $value;
        } else {
            throw new \LogicException("Property $name is not defined.");
        }
    }

}

If the property has read access only, you can use the @property-read annotation instead.

Of course, you may also just have mistyped another name, in which case you should fix the error.

See also the PhpDoc documentation for @property.

Loading history...
215
      [
216
        'title'  => $title,
217
        'action' => $action,
218
        'form'   => $form->getHTML(array('novalidate' => true))
219
      ]);
220
  }
221
  
222
  /**
223
   * Edit content in database
224
   *
225
   * @Param     Integer   $id   Index for content to edit
226
   * @Return    Void
227
   */
228
  public function editAction($id = null){
229
    $action = "Edit";
230
    $title  = "{$action} content";
231
    $url    = $this->url->create($this->urlPrefix . 'content/');
0 ignored issues
show
Documentation introduced by
The property url does not exist on object<Chp\TextContent\ContentController>. Since you implemented __get, maybe consider adding a @property annotation.

Since your code implements the magic getter _get, this function will be called for any read access on an undefined variable. You can add the @property annotation to your class or interface to document the existence of this variable.

<?php

/**
 * @property int $x
 * @property int $y
 * @property string $text
 */
class MyLabel
{
    private $properties;

    private $allowedProperties = array('x', 'y', 'text');

    public function __get($name)
    {
        if (isset($properties[$name]) && in_array($name, $this->allowedProperties)) {
            return $properties[$name];
        } else {
            return null;
        }
    }

    public function __set($name, $value)
    {
        if (in_array($name, $this->allowedProperties)) {
            $properties[$name] = $value;
        } else {
            throw new \LogicException("Property $name is not defined.");
        }
    }

}

If the property has read access only, you can use the @property-read annotation instead.

Of course, you may also just have mistyped another name, in which case you should fix the error.

See also the PhpDoc documentation for @property.

Loading history...
232
    
233
    if(is_null($id) || !is_numeric($id))
234
      $this->response->redirect($url);
0 ignored issues
show
Documentation introduced by
The property response does not exist on object<Chp\TextContent\ContentController>. Since you implemented __get, maybe consider adding a @property annotation.

Since your code implements the magic getter _get, this function will be called for any read access on an undefined variable. You can add the @property annotation to your class or interface to document the existence of this variable.

<?php

/**
 * @property int $x
 * @property int $y
 * @property string $text
 */
class MyLabel
{
    private $properties;

    private $allowedProperties = array('x', 'y', 'text');

    public function __get($name)
    {
        if (isset($properties[$name]) && in_array($name, $this->allowedProperties)) {
            return $properties[$name];
        } else {
            return null;
        }
    }

    public function __set($name, $value)
    {
        if (in_array($name, $this->allowedProperties)) {
            $properties[$name] = $value;
        } else {
            throw new \LogicException("Property $name is not defined.");
        }
    }

}

If the property has read access only, you can use the @property-read annotation instead.

Of course, you may also just have mistyped another name, in which case you should fix the error.

See also the PhpDoc documentation for @property.

Loading history...
235
    
236
    $content = $this->content->getContentById($id, false);
237
    
238
    if(is_null($content->id))
239
      $this->response->redirect($url);
0 ignored issues
show
Documentation introduced by
The property response does not exist on object<Chp\TextContent\ContentController>. Since you implemented __get, maybe consider adding a @property annotation.

Since your code implements the magic getter _get, this function will be called for any read access on an undefined variable. You can add the @property annotation to your class or interface to document the existence of this variable.

<?php

/**
 * @property int $x
 * @property int $y
 * @property string $text
 */
class MyLabel
{
    private $properties;

    private $allowedProperties = array('x', 'y', 'text');

    public function __get($name)
    {
        if (isset($properties[$name]) && in_array($name, $this->allowedProperties)) {
            return $properties[$name];
        } else {
            return null;
        }
    }

    public function __set($name, $value)
    {
        if (in_array($name, $this->allowedProperties)) {
            $properties[$name] = $value;
        } else {
            throw new \LogicException("Property $name is not defined.");
        }
    }

}

If the property has read access only, you can use the @property-read annotation instead.

Of course, you may also just have mistyped another name, in which case you should fix the error.

See also the PhpDoc documentation for @property.

Loading history...
240
    
241
    $form = $this->contentForm(strtolower($action), $content);
242
    $form->check();
243
    
244
    $this->theme->setTitle($title);
0 ignored issues
show
Documentation introduced by
The property theme does not exist on object<Chp\TextContent\ContentController>. Since you implemented __get, maybe consider adding a @property annotation.

Since your code implements the magic getter _get, this function will be called for any read access on an undefined variable. You can add the @property annotation to your class or interface to document the existence of this variable.

<?php

/**
 * @property int $x
 * @property int $y
 * @property string $text
 */
class MyLabel
{
    private $properties;

    private $allowedProperties = array('x', 'y', 'text');

    public function __get($name)
    {
        if (isset($properties[$name]) && in_array($name, $this->allowedProperties)) {
            return $properties[$name];
        } else {
            return null;
        }
    }

    public function __set($name, $value)
    {
        if (in_array($name, $this->allowedProperties)) {
            $properties[$name] = $value;
        } else {
            throw new \LogicException("Property $name is not defined.");
        }
    }

}

If the property has read access only, you can use the @property-read annotation instead.

Of course, you may also just have mistyped another name, in which case you should fix the error.

See also the PhpDoc documentation for @property.

Loading history...
245
    
246
    $this->views->add('text-content/post', 
0 ignored issues
show
Documentation introduced by
The property views does not exist on object<Chp\TextContent\ContentController>. Since you implemented __get, maybe consider adding a @property annotation.

Since your code implements the magic getter _get, this function will be called for any read access on an undefined variable. You can add the @property annotation to your class or interface to document the existence of this variable.

<?php

/**
 * @property int $x
 * @property int $y
 * @property string $text
 */
class MyLabel
{
    private $properties;

    private $allowedProperties = array('x', 'y', 'text');

    public function __get($name)
    {
        if (isset($properties[$name]) && in_array($name, $this->allowedProperties)) {
            return $properties[$name];
        } else {
            return null;
        }
    }

    public function __set($name, $value)
    {
        if (in_array($name, $this->allowedProperties)) {
            $properties[$name] = $value;
        } else {
            throw new \LogicException("Property $name is not defined.");
        }
    }

}

If the property has read access only, you can use the @property-read annotation instead.

Of course, you may also just have mistyped another name, in which case you should fix the error.

See also the PhpDoc documentation for @property.

Loading history...
247
      [
248
        'title'  => $title,
249
        'action' => $action,
250
        'form'   => $form->getHTML(array('novalidate' => true))
251
      ]
252
    );
253
  }
254
	
255
	/**
256
	 * Remove content
257
	 *
258
   * @Param   Integer  $id      Index to content to remove
259
	 * @Return  String   $error  	Database-error msg
260
	 */
261
	public function removeAction($id = null){
262
		$action = "Delete";
263
    $title = "Delete content";
264
    $url = $this->url->create($this->urlPrefix . "content/");
0 ignored issues
show
Documentation introduced by
The property url does not exist on object<Chp\TextContent\ContentController>. Since you implemented __get, maybe consider adding a @property annotation.

Since your code implements the magic getter _get, this function will be called for any read access on an undefined variable. You can add the @property annotation to your class or interface to document the existence of this variable.

<?php

/**
 * @property int $x
 * @property int $y
 * @property string $text
 */
class MyLabel
{
    private $properties;

    private $allowedProperties = array('x', 'y', 'text');

    public function __get($name)
    {
        if (isset($properties[$name]) && in_array($name, $this->allowedProperties)) {
            return $properties[$name];
        } else {
            return null;
        }
    }

    public function __set($name, $value)
    {
        if (in_array($name, $this->allowedProperties)) {
            $properties[$name] = $value;
        } else {
            throw new \LogicException("Property $name is not defined.");
        }
    }

}

If the property has read access only, you can use the @property-read annotation instead.

Of course, you may also just have mistyped another name, in which case you should fix the error.

See also the PhpDoc documentation for @property.

Loading history...
265
    
266
    if(is_null($id) || !is_numeric($id)){
267
			$this->response->redirect($url);
0 ignored issues
show
Documentation introduced by
The property response does not exist on object<Chp\TextContent\ContentController>. Since you implemented __get, maybe consider adding a @property annotation.

Since your code implements the magic getter _get, this function will be called for any read access on an undefined variable. You can add the @property annotation to your class or interface to document the existence of this variable.

<?php

/**
 * @property int $x
 * @property int $y
 * @property string $text
 */
class MyLabel
{
    private $properties;

    private $allowedProperties = array('x', 'y', 'text');

    public function __get($name)
    {
        if (isset($properties[$name]) && in_array($name, $this->allowedProperties)) {
            return $properties[$name];
        } else {
            return null;
        }
    }

    public function __set($name, $value)
    {
        if (in_array($name, $this->allowedProperties)) {
            $properties[$name] = $value;
        } else {
            throw new \LogicException("Property $name is not defined.");
        }
    }

}

If the property has read access only, you can use the @property-read annotation instead.

Of course, you may also just have mistyped another name, in which case you should fix the error.

See also the PhpDoc documentation for @property.

Loading history...
268
		}
269
    
270
    $content = $this->content->find($id);
271
    
272
    if(is_null($content->id)){
273
      $this->response->redirect($url);
0 ignored issues
show
Documentation introduced by
The property response does not exist on object<Chp\TextContent\ContentController>. Since you implemented __get, maybe consider adding a @property annotation.

Since your code implements the magic getter _get, this function will be called for any read access on an undefined variable. You can add the @property annotation to your class or interface to document the existence of this variable.

<?php

/**
 * @property int $x
 * @property int $y
 * @property string $text
 */
class MyLabel
{
    private $properties;

    private $allowedProperties = array('x', 'y', 'text');

    public function __get($name)
    {
        if (isset($properties[$name]) && in_array($name, $this->allowedProperties)) {
            return $properties[$name];
        } else {
            return null;
        }
    }

    public function __set($name, $value)
    {
        if (in_array($name, $this->allowedProperties)) {
            $properties[$name] = $value;
        } else {
            throw new \LogicException("Property $name is not defined.");
        }
    }

}

If the property has read access only, you can use the @property-read annotation instead.

Of course, you may also just have mistyped another name, in which case you should fix the error.

See also the PhpDoc documentation for @property.

Loading history...
274
    }
275
    
276
    $form = $this->confirmForm($url);
277
    $status = $form->Check();
278
    
279
    if ($status === true) {
280
      $now = date('Y-m-d H:i:s');
281
      
282
      $content->deleted = $now;
283
      $content->save();
284
      
285
      $this->response->redirect($url);
0 ignored issues
show
Documentation introduced by
The property response does not exist on object<Chp\TextContent\ContentController>. Since you implemented __get, maybe consider adding a @property annotation.

Since your code implements the magic getter _get, this function will be called for any read access on an undefined variable. You can add the @property annotation to your class or interface to document the existence of this variable.

<?php

/**
 * @property int $x
 * @property int $y
 * @property string $text
 */
class MyLabel
{
    private $properties;

    private $allowedProperties = array('x', 'y', 'text');

    public function __get($name)
    {
        if (isset($properties[$name]) && in_array($name, $this->allowedProperties)) {
            return $properties[$name];
        } else {
            return null;
        }
    }

    public function __set($name, $value)
    {
        if (in_array($name, $this->allowedProperties)) {
            $properties[$name] = $value;
        } else {
            throw new \LogicException("Property $name is not defined.");
        }
    }

}

If the property has read access only, you can use the @property-read annotation instead.

Of course, you may also just have mistyped another name, in which case you should fix the error.

See also the PhpDoc documentation for @property.

Loading history...
286
    }
287
    
288
    $this->theme->setTitle($title);
0 ignored issues
show
Documentation introduced by
The property theme does not exist on object<Chp\TextContent\ContentController>. Since you implemented __get, maybe consider adding a @property annotation.

Since your code implements the magic getter _get, this function will be called for any read access on an undefined variable. You can add the @property annotation to your class or interface to document the existence of this variable.

<?php

/**
 * @property int $x
 * @property int $y
 * @property string $text
 */
class MyLabel
{
    private $properties;

    private $allowedProperties = array('x', 'y', 'text');

    public function __get($name)
    {
        if (isset($properties[$name]) && in_array($name, $this->allowedProperties)) {
            return $properties[$name];
        } else {
            return null;
        }
    }

    public function __set($name, $value)
    {
        if (in_array($name, $this->allowedProperties)) {
            $properties[$name] = $value;
        } else {
            throw new \LogicException("Property $name is not defined.");
        }
    }

}

If the property has read access only, you can use the @property-read annotation instead.

Of course, you may also just have mistyped another name, in which case you should fix the error.

See also the PhpDoc documentation for @property.

Loading history...
289
    $this->views->add('text-content/action', [
0 ignored issues
show
Documentation introduced by
The property views does not exist on object<Chp\TextContent\ContentController>. Since you implemented __get, maybe consider adding a @property annotation.

Since your code implements the magic getter _get, this function will be called for any read access on an undefined variable. You can add the @property annotation to your class or interface to document the existence of this variable.

<?php

/**
 * @property int $x
 * @property int $y
 * @property string $text
 */
class MyLabel
{
    private $properties;

    private $allowedProperties = array('x', 'y', 'text');

    public function __get($name)
    {
        if (isset($properties[$name]) && in_array($name, $this->allowedProperties)) {
            return $properties[$name];
        } else {
            return null;
        }
    }

    public function __set($name, $value)
    {
        if (in_array($name, $this->allowedProperties)) {
            $properties[$name] = $value;
        } else {
            throw new \LogicException("Property $name is not defined.");
        }
    }

}

If the property has read access only, you can use the @property-read annotation instead.

Of course, you may also just have mistyped another name, in which case you should fix the error.

See also the PhpDoc documentation for @property.

Loading history...
290
      'title'  => $title,
291
      'toDo'    => strtolower($action),
292
      'toWhat'  => strtolower($this->getTypeTitle($content->type)),
293
      'which'   => htmlentities($content->title),
294
      'form'    => $form->getHTML(['novalidate' => true]),
295
    ], 'main');
296
	}
297
  
298
  /**
299
   * Prepare form to add or edit content
300
   *
301
   * @Param   String    $type       Selected content-type
302
   * @Param   Boolean   $published  If content should be published already
303
   * @Return  Object    $form       CForm object
304
   */
305
  private function listForm($type = null, $published = false){
306
    
307
    $type_options      = array_merge([0 => "Select a type of content"], $this->getTypes());
308
    
309
    $form = new \Mos\HTMLForm\CForm([], [
310
        'type' => [
311
          'type'        => 'select',
312
          'label'       => 'Type of content:',
313
          'options'     => $type_options,
314
          'value'       => (isset($type)) ? $type : ''
315
        ],
316
        'published' => [
317
          'type'        => 'checkbox',
318
          'label'       => 'Published',
319
          'checked'     => $published,
320
          'value'       => 1
321
        ],
322
        'submit' => [
323
          'value' 		=> 'Filter',
324
          'type'      => 'submit',
325
          'callback'  => function ($form) {
326
            $published = ($this->request->getPost('published')) ? 1 : 0;
0 ignored issues
show
Documentation introduced by
The property request does not exist on object<Chp\TextContent\ContentController>. Since you implemented __get, maybe consider adding a @property annotation.

Since your code implements the magic getter _get, this function will be called for any read access on an undefined variable. You can add the @property annotation to your class or interface to document the existence of this variable.

<?php

/**
 * @property int $x
 * @property int $y
 * @property string $text
 */
class MyLabel
{
    private $properties;

    private $allowedProperties = array('x', 'y', 'text');

    public function __get($name)
    {
        if (isset($properties[$name]) && in_array($name, $this->allowedProperties)) {
            return $properties[$name];
        } else {
            return null;
        }
    }

    public function __set($name, $value)
    {
        if (in_array($name, $this->allowedProperties)) {
            $properties[$name] = $value;
        } else {
            throw new \LogicException("Property $name is not defined.");
        }
    }

}

If the property has read access only, you can use the @property-read annotation instead.

Of course, you may also just have mistyped another name, in which case you should fix the error.

See also the PhpDoc documentation for @property.

Loading history...
327
            $type      = $form->Value('type');
328
            
329
            $this->response->redirect($this->url->create($this->urlPrefix . "content/list/{$type}/{$published}"));
0 ignored issues
show
Documentation introduced by
The property response does not exist on object<Chp\TextContent\ContentController>. Since you implemented __get, maybe consider adding a @property annotation.

Since your code implements the magic getter _get, this function will be called for any read access on an undefined variable. You can add the @property annotation to your class or interface to document the existence of this variable.

<?php

/**
 * @property int $x
 * @property int $y
 * @property string $text
 */
class MyLabel
{
    private $properties;

    private $allowedProperties = array('x', 'y', 'text');

    public function __get($name)
    {
        if (isset($properties[$name]) && in_array($name, $this->allowedProperties)) {
            return $properties[$name];
        } else {
            return null;
        }
    }

    public function __set($name, $value)
    {
        if (in_array($name, $this->allowedProperties)) {
            $properties[$name] = $value;
        } else {
            throw new \LogicException("Property $name is not defined.");
        }
    }

}

If the property has read access only, you can use the @property-read annotation instead.

Of course, you may also just have mistyped another name, in which case you should fix the error.

See also the PhpDoc documentation for @property.

Loading history...
Documentation introduced by
The property url does not exist on object<Chp\TextContent\ContentController>. Since you implemented __get, maybe consider adding a @property annotation.

Since your code implements the magic getter _get, this function will be called for any read access on an undefined variable. You can add the @property annotation to your class or interface to document the existence of this variable.

<?php

/**
 * @property int $x
 * @property int $y
 * @property string $text
 */
class MyLabel
{
    private $properties;

    private $allowedProperties = array('x', 'y', 'text');

    public function __get($name)
    {
        if (isset($properties[$name]) && in_array($name, $this->allowedProperties)) {
            return $properties[$name];
        } else {
            return null;
        }
    }

    public function __set($name, $value)
    {
        if (in_array($name, $this->allowedProperties)) {
            $properties[$name] = $value;
        } else {
            throw new \LogicException("Property $name is not defined.");
        }
    }

}

If the property has read access only, you can use the @property-read annotation instead.

Of course, you may also just have mistyped another name, in which case you should fix the error.

See also the PhpDoc documentation for @property.

Loading history...
330
          }
331
        ]
332
    ]);
333
    
334
    return $form;
335
  }
336
  
337
  /**
338
   * Prepare form to add or edit content
339
   *
340
   * @Param   String    $action     What to do (add or edit)
341
   * @Param   Object    $values     Content values to add form elements
342
   * @Return  Object    $form       CForm object
343
   */
344 1
  private function contentForm($action, $values = null){
345
    if(isset($values) && is_object($values)){
346
      $valArr = get_object_vars($values);
347
      extract($valArr);
348
    }
349
    
350
    $slug = (isset($slug)) ? $slug : NULL;
351
    
352
    $type_options      = $this->getTypes();
353
    
354
    $form = new \Mos\HTMLForm\CForm([], [
355
        'id'      => [
356
          'type'        => 'hidden',
357
          'value'       => (isset($id)) ? $id : 0
358
        ],
359
        'title' => [
360
          'type'        => 'text',
361
          'label'       => 'Title: (Between ' . $this->minimumLength . ' to 80 chars)',
362
          'maxlength'   => 80,
363
          'required'    => true,
364
          'value'       => (isset($title)) ? $title : '',
365
          'validation'  => [
366
                              'custom_test' => array(
367
                                'message' => 'Minmum length is ' . $this->minimumLength . ' chars.', 
368
                                'test'    => array($this, 'minimumLength')
369
                              )
370
                           ]
371
        ],
372
        'url' => [
373
          'type'        => 'text',
374
          'label'       => 'Url:',
375
          'maxlength'   => 80,
376
          'value'       => (isset($url)) ? $url : '',
377
          'required'    => false, 
378 1
          'validation'  => [
379
                              'custom_test' => array(
380
                                'message' => 'Url is not in accepted-format for url:s (accepted characters is \'a-z0-9-_()\').', 
381
                                'test'    => array($this, 'validateSlug')
382
                              )
383
                           ]
384
        ],
385
        'ingress' => [
386
          'type'        => 'textarea',
387
          'label'       => 'Ingress: (minimum 3 chars)',
388
          'value'       => (isset($ingress)) ? $ingress : '',
389
          'required'    => true,
390
          'validation'  => [
391
                              'custom_test' => array(
392
                                'message' => 'Minmum length is ' . $this->minimumLength . ' chars.', 
393
                                'test'    => array($this, 'minimumLength')
394
                              )
395
                           ]
396
        ],
397
        'text' => [
398
          'type'        => 'textarea',
399
        	'label'       => 'Text: (minimum 3 chars)',
400
          'value'       => (isset($text)) ? $text : '',
401
          'required'    => true,
402
          'validation'  => [
403
                            'custom_test' => array(
404
                              'message' => 'Minmum length is ' . $this->minimumLength . ' chars.', 
405
                              'test'    => array($this, 'minimumLength')
406
                            )
407
                           ]
408
        ],
409
        'type' => [
410
          'type'        => 'select',
411
          'label'       => 'Type of content:',
412
          'options'     => $type_options,
413
          'value'       => (isset($type)) ? $type : '',
414
          'required'    => true,
415
          'validation'  => [
416
                              'not_empty',
417
                              'custom_test' => array(
418
                                'message' => 'You need to select a existing type.', 
419
                                'test'    => array($this, 'checkType')
420
                              )
421
                           ]
422
        ],
423
        'tags' => [
424
          'type'        => 'text',
425
          'label'       => 'Tags: (Seperate by \',\')',
426
          'value'       => (isset($tags)) ? $tags : '',
427
          'required'    => false
428
        ],
429
        'filters' => [
430
          'type'        => 'checkbox-multiple',
431
          'label'       => 'Text filter:',
432
          'values'      => $this->filters,
433
          'checked'     => (isset($filters)) ? explode(',', $filters) : array(),
434
          'validation'  => [
435
                              'custom_test' => array(
436
                                'message' => 'You need to select a existing type.', 
437
                                'test'    => array($this, 'checkFilter')
438
                              )
439
                           ]
440
        ],
441
        'published' => [
442
          'type'        => 'datetime',
443
          'label'       => 'Published: (YYYY-MM-DD HH:MM:SS)',
444
          'value'       => (isset($published)) ? $published : '',
445
          'validation'  => [
446
                              'custom_test' => array(
447
                                'message' => 'It need to be in a correct date and time with format: YYYY-MM-DD HH:MM:SS.', 
448
                                'test'    => array($this, 'checkDatetime')
449
                              )
450
                           ]
451
        ],
452
        'publishedNow' => [
453
          'type'        => 'checkbox',
454
          'label'       => 'Publish now:',
455
          'checked'     => (!isset($published) && !isset($id)),
456
          'value'       => 'yes'
457
        ],
458
        'submit' => [
459
          'value' 		=> 'Save',
460
          'type'      => 'submit',
461
          'callback'  => function ($form) use($slug, $action) {
462
            return $this->saveContent($form, $slug, $action);
463
          }
464
        ]
465
    ]);
466
    
467
    return $form;
468
  }
469
  
470
  /**
471
   * Prepare confirmation form
472
   *
473
   * @Param   String   $returnUrl       Return url
474
   * @Return  Object   $form            Form-object
475
   */
476
  public function confirmForm($returnUrl = null){
477
    $returnUrl = (isset($returnUrl)) ? $returnUrl : $this->request->getBaseUrl();
0 ignored issues
show
Documentation introduced by
The property request does not exist on object<Chp\TextContent\ContentController>. Since you implemented __get, maybe consider adding a @property annotation.

Since your code implements the magic getter _get, this function will be called for any read access on an undefined variable. You can add the @property annotation to your class or interface to document the existence of this variable.

<?php

/**
 * @property int $x
 * @property int $y
 * @property string $text
 */
class MyLabel
{
    private $properties;

    private $allowedProperties = array('x', 'y', 'text');

    public function __get($name)
    {
        if (isset($properties[$name]) && in_array($name, $this->allowedProperties)) {
            return $properties[$name];
        } else {
            return null;
        }
    }

    public function __set($name, $value)
    {
        if (in_array($name, $this->allowedProperties)) {
            $properties[$name] = $value;
        } else {
            throw new \LogicException("Property $name is not defined.");
        }
    }

}

If the property has read access only, you can use the @property-read annotation instead.

Of course, you may also just have mistyped another name, in which case you should fix the error.

See also the PhpDoc documentation for @property.

Loading history...
478
    
479
    $form = new \Mos\HTMLForm\CForm([], [
480
        'submit' => [
481
          'type'     => 'submit',
482
          'value'    => 'Yes',
483
          'callback' => function() {
484
            return true;
485
          }
486
        ],
487
        'submit-no' => [
488
          'type'     => "submit",
489
          'value'    => 'No',
490
          'callback' => function() use($returnUrl) {
491
            $this->response->redirect($returnUrl);
0 ignored issues
show
Documentation introduced by
The property response does not exist on object<Chp\TextContent\ContentController>. Since you implemented __get, maybe consider adding a @property annotation.

Since your code implements the magic getter _get, this function will be called for any read access on an undefined variable. You can add the @property annotation to your class or interface to document the existence of this variable.

<?php

/**
 * @property int $x
 * @property int $y
 * @property string $text
 */
class MyLabel
{
    private $properties;

    private $allowedProperties = array('x', 'y', 'text');

    public function __get($name)
    {
        if (isset($properties[$name]) && in_array($name, $this->allowedProperties)) {
            return $properties[$name];
        } else {
            return null;
        }
    }

    public function __set($name, $value)
    {
        if (in_array($name, $this->allowedProperties)) {
            $properties[$name] = $value;
        } else {
            throw new \LogicException("Property $name is not defined.");
        }
    }

}

If the property has read access only, you can use the @property-read annotation instead.

Of course, you may also just have mistyped another name, in which case you should fix the error.

See also the PhpDoc documentation for @property.

Loading history...
492
          }
493
        ]
494
      ]
495
    );
496
		
497
    // Check the status of the form
498
    return $form;
499
  }
500
  
501
  /**
502
   * Save content to database
503
   *
504
   * @Param   Object    $form     Form object
505
   * @Param   String    $slug     Old slug for content to compare
506
   * @Param   String    $action   Edit or make new content
507
   * @Return  Boolean   false     If saving fail, return false
508
   */
509
  private function saveContent($form, $slug = null, $action){
510
    // Prepare content for saving
511
    $content = $this->prepareSaveContent($form, $slug, $action);
0 ignored issues
show
Unused Code introduced by
The call to ContentController::prepareSaveContent() has too many arguments starting with $action.

This check compares calls to functions or methods with their respective definitions. If the call has more arguments than are defined, it raises an issue.

If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress.

In this case you can add the @ignore PhpDoc annotation to the duplicate definition and it will be ignored.

Loading history...
512
    
513
    // Save content
514
    $content = $this->content->save($content);
515
    
516
    // Saving fail
517
    if(!$this->content->id)
518
      return false;
519
    // Save tags for content to database
520
    else if($content['id'] != 0)
521
      $this->saveTags($form->Value('tags'), $this->content->id);
1 ignored issue
show
Bug introduced by
The property id does not seem to exist in Chp\TextContent\Content.

An attempt at access to an undefined property has been detected. This may either be a typographical error or the property has been renamed but there are still references to its old name.

If you really want to allow access to undefined properties, you can define magic methods to allow access. See the php core documentation on Overloading.

Loading history...
522
    
523
    $this->response->redirect($this->url->create($this->urlPrefix . "content/"));
0 ignored issues
show
Documentation introduced by
The property response does not exist on object<Chp\TextContent\ContentController>. Since you implemented __get, maybe consider adding a @property annotation.

Since your code implements the magic getter _get, this function will be called for any read access on an undefined variable. You can add the @property annotation to your class or interface to document the existence of this variable.

<?php

/**
 * @property int $x
 * @property int $y
 * @property string $text
 */
class MyLabel
{
    private $properties;

    private $allowedProperties = array('x', 'y', 'text');

    public function __get($name)
    {
        if (isset($properties[$name]) && in_array($name, $this->allowedProperties)) {
            return $properties[$name];
        } else {
            return null;
        }
    }

    public function __set($name, $value)
    {
        if (in_array($name, $this->allowedProperties)) {
            $properties[$name] = $value;
        } else {
            throw new \LogicException("Property $name is not defined.");
        }
    }

}

If the property has read access only, you can use the @property-read annotation instead.

Of course, you may also just have mistyped another name, in which case you should fix the error.

See also the PhpDoc documentation for @property.

Loading history...
Documentation introduced by
The property url does not exist on object<Chp\TextContent\ContentController>. Since you implemented __get, maybe consider adding a @property annotation.

Since your code implements the magic getter _get, this function will be called for any read access on an undefined variable. You can add the @property annotation to your class or interface to document the existence of this variable.

<?php

/**
 * @property int $x
 * @property int $y
 * @property string $text
 */
class MyLabel
{
    private $properties;

    private $allowedProperties = array('x', 'y', 'text');

    public function __get($name)
    {
        if (isset($properties[$name]) && in_array($name, $this->allowedProperties)) {
            return $properties[$name];
        } else {
            return null;
        }
    }

    public function __set($name, $value)
    {
        if (in_array($name, $this->allowedProperties)) {
            $properties[$name] = $value;
        } else {
            throw new \LogicException("Property $name is not defined.");
        }
    }

}

If the property has read access only, you can use the @property-read annotation instead.

Of course, you may also just have mistyped another name, in which case you should fix the error.

See also the PhpDoc documentation for @property.

Loading history...
524
  }
525
526
  /**
527
   * Save tags for content to database
528
   *
529
   * @Param   String   $tags     Tags for content
530
   * @Param   Int      $id       Content index
531
   */
532
  private function saveTags($tags, $id){
533
    $this->db->delete(
0 ignored issues
show
Documentation introduced by
The property db does not exist on object<Chp\TextContent\ContentController>. Since you implemented __get, maybe consider adding a @property annotation.

Since your code implements the magic getter _get, this function will be called for any read access on an undefined variable. You can add the @property annotation to your class or interface to document the existence of this variable.

<?php

/**
 * @property int $x
 * @property int $y
 * @property string $text
 */
class MyLabel
{
    private $properties;

    private $allowedProperties = array('x', 'y', 'text');

    public function __get($name)
    {
        if (isset($properties[$name]) && in_array($name, $this->allowedProperties)) {
            return $properties[$name];
        } else {
            return null;
        }
    }

    public function __set($name, $value)
    {
        if (in_array($name, $this->allowedProperties)) {
            $properties[$name] = $value;
        } else {
            throw new \LogicException("Property $name is not defined.");
        }
    }

}

If the property has read access only, you can use the @property-read annotation instead.

Of course, you may also just have mistyped another name, in which case you should fix the error.

See also the PhpDoc documentation for @property.

Loading history...
534
      'content_tags',
535
      'idContent = ?'
536
    )->execute([$id]);
537
    
538
    $this->db->insert(
0 ignored issues
show
Documentation introduced by
The property db does not exist on object<Chp\TextContent\ContentController>. Since you implemented __get, maybe consider adding a @property annotation.

Since your code implements the magic getter _get, this function will be called for any read access on an undefined variable. You can add the @property annotation to your class or interface to document the existence of this variable.

<?php

/**
 * @property int $x
 * @property int $y
 * @property string $text
 */
class MyLabel
{
    private $properties;

    private $allowedProperties = array('x', 'y', 'text');

    public function __get($name)
    {
        if (isset($properties[$name]) && in_array($name, $this->allowedProperties)) {
            return $properties[$name];
        } else {
            return null;
        }
    }

    public function __set($name, $value)
    {
        if (in_array($name, $this->allowedProperties)) {
            $properties[$name] = $value;
        } else {
            throw new \LogicException("Property $name is not defined.");
        }
    }

}

If the property has read access only, you can use the @property-read annotation instead.

Of course, you may also just have mistyped another name, in which case you should fix the error.

See also the PhpDoc documentation for @property.

Loading history...
539
      'content_tags',
540
      ['idContent', 'tag', 'slug']
541
    );
542
    
543
    if(isset($tags) && !is_null($tags)){
544
      $tagsArr = explode(",", $tags);
545
      
546
      foreach($tagsArr as $tag){
547
        $tag = trim($tag);
548
        $this->db->execute([
0 ignored issues
show
Documentation introduced by
The property db does not exist on object<Chp\TextContent\ContentController>. Since you implemented __get, maybe consider adding a @property annotation.

Since your code implements the magic getter _get, this function will be called for any read access on an undefined variable. You can add the @property annotation to your class or interface to document the existence of this variable.

<?php

/**
 * @property int $x
 * @property int $y
 * @property string $text
 */
class MyLabel
{
    private $properties;

    private $allowedProperties = array('x', 'y', 'text');

    public function __get($name)
    {
        if (isset($properties[$name]) && in_array($name, $this->allowedProperties)) {
            return $properties[$name];
        } else {
            return null;
        }
    }

    public function __set($name, $value)
    {
        if (in_array($name, $this->allowedProperties)) {
            $properties[$name] = $value;
        } else {
            throw new \LogicException("Property $name is not defined.");
        }
    }

}

If the property has read access only, you can use the @property-read annotation instead.

Of course, you may also just have mistyped another name, in which case you should fix the error.

See also the PhpDoc documentation for @property.

Loading history...
549
          $id,
550
          $tag,
551
          $this->slugify($tag)
552
        ]);
553
      }
554
    }
555
  }
556
  
557
  /**
558
   * Prepare contents for show in list view
559
   *
560
   * @Param   Array   $contents   Array with content objects
561
   * @Return  Array   $results    Array with prepare content objects
562
   */
563 1
  public function prepareListContent($contents){
564 1
    $results = array();
565
    
566 1
    foreach($contents AS $key => $content){
567 1
      $available = $this->checkIfAvailable($content->published);
568 1
      $results[$key] = (object)[];
569
      
570 1
      foreach($content as $key2 => $value){
571 1
        $results[$key]->{$key2} = $value;
572 1
      }
573
      
574 1
      $results[$key]->typeTxt      = $this->getTypeTitle($content->type);
575 1
      $results[$key]->title        = htmlspecialchars($content->title, ENT_QUOTES);
576 1
      $results[$key]->editUrl      = $this->url->create($this->urlPrefix . "content/edit/{$content->id}");
0 ignored issues
show
Documentation introduced by
The property url does not exist on object<Chp\TextContent\ContentController>. Since you implemented __get, maybe consider adding a @property annotation.

Since your code implements the magic getter _get, this function will be called for any read access on an undefined variable. You can add the @property annotation to your class or interface to document the existence of this variable.

<?php

/**
 * @property int $x
 * @property int $y
 * @property string $text
 */
class MyLabel
{
    private $properties;

    private $allowedProperties = array('x', 'y', 'text');

    public function __get($name)
    {
        if (isset($properties[$name]) && in_array($name, $this->allowedProperties)) {
            return $properties[$name];
        } else {
            return null;
        }
    }

    public function __set($name, $value)
    {
        if (in_array($name, $this->allowedProperties)) {
            $properties[$name] = $value;
        } else {
            throw new \LogicException("Property $name is not defined.");
        }
    }

}

If the property has read access only, you can use the @property-read annotation instead.

Of course, you may also just have mistyped another name, in which case you should fix the error.

See also the PhpDoc documentation for @property.

Loading history...
577 1
      $results[$key]->removeUrl    = $this->url->create($this->urlPrefix . "content/remove/{$content->id}");
0 ignored issues
show
Documentation introduced by
The property url does not exist on object<Chp\TextContent\ContentController>. Since you implemented __get, maybe consider adding a @property annotation.

Since your code implements the magic getter _get, this function will be called for any read access on an undefined variable. You can add the @property annotation to your class or interface to document the existence of this variable.

<?php

/**
 * @property int $x
 * @property int $y
 * @property string $text
 */
class MyLabel
{
    private $properties;

    private $allowedProperties = array('x', 'y', 'text');

    public function __get($name)
    {
        if (isset($properties[$name]) && in_array($name, $this->allowedProperties)) {
            return $properties[$name];
        } else {
            return null;
        }
    }

    public function __set($name, $value)
    {
        if (in_array($name, $this->allowedProperties)) {
            $properties[$name] = $value;
        } else {
            throw new \LogicException("Property $name is not defined.");
        }
    }

}

If the property has read access only, you can use the @property-read annotation instead.

Of course, you may also just have mistyped another name, in which case you should fix the error.

See also the PhpDoc documentation for @property.

Loading history...
578 1
      $results[$key]->showUrl      = $this->getUrlToContent($content);
579 1
      $results[$key]->available    = ((!$available) ? "not-" : null) . "published";
580 1
      $results[$key]->publishedTxt  = ($available) ? $contents[$key]->published : "Not published yet";
581 1
    }
582
    
583 1
    return $results;
584
  }
585
  /**
586
   * Prepare save of content to database
587
   *
588
   * @Param   Object    $form     Form object
589
   * @Param   String    $slug     Old slug for content to compare
590
   * @Return  Array     $content  Prepare content array
591
   */  
592 1
  public function prepareSaveContent($form, $slug = null){
593 1
    $now = date('Y-m-d H:i:s');
594
    
595 1
    $newSlug = $this->slugify($form->Value('title'));
596
    
597 1
    if($slug != $newSlug && isset($newSlug))
598 1
      $newSlug = $this->content->makeSlugToContent($newSlug, $form->Value('type'));
599
    
600
    $content = array(
601 1
      'title'     => $form->Value('title'),
602 1
      'slug'      => $newSlug,
603 1
      'url'       => $this->slugify($form->Value('url')),
604 1
      'ingress'   => $form->Value('ingress'),
605 1
      'text'      => $form->Value('text'),
606 1
      'type'      => $form->Value('type'),
607 1
      'filters'   => ($form->Value('filters')) ? implode(",", $form->Value('filters')) : '',
608 1
      'published' => ($form->Value('publishedNow') && $form->Value('publishedNow') == 'yes') ? $now : $form->Value('published')
609 1
    );
610
    
611 1
    $id = ($form->Value('id')) ? intval($form->Value('id')) : 0;
612
    
613 1
    if($id != 0){
614 1
      $content['updated'] = $now;
615 1
      $content['id']      = $id;
616 1
    }
617
    else{
618 1
      $content['created'] = $now;
619 1
      $content['author']  = 0;//$this->user->getUserId();
620
    }
621
    
622 1
    return $content;
623
  }
624
  
625
  /**
626
   * Check if content is published
627
   *
628
   * @Param   String      $datetime     When it will be published
629
   * @Return  Boolean     True/false    Validate result
630
   */
631 2
  public function checkIfAvailable($datetime){
632 2
    return ($datetime <= date('Y-m-d H:i:s')) ? true : false;
633
  }
634
  
635
  /**
636
	 * Create a link to the content, based on its type.
637
	 *
638
	 * @Param  	Object  	$content	Content to link to
639
	 * @Return 	String    	   	 	  With url for content
640
	 */
641 2
	public function getUrlToContent($content) {
642 2
    if(isset($this->types[$content->type])){
643 2
      $type = $this->types[$content->type]; // Get type from type index
644
	  
645 2
      return $this->url->create($this->urlPrefix . "{$type['url']}{$type['perfix']}{$content->{$type['field']}}");
0 ignored issues
show
Documentation introduced by
The property url does not exist on object<Chp\TextContent\ContentController>. Since you implemented __get, maybe consider adding a @property annotation.

Since your code implements the magic getter _get, this function will be called for any read access on an undefined variable. You can add the @property annotation to your class or interface to document the existence of this variable.

<?php

/**
 * @property int $x
 * @property int $y
 * @property string $text
 */
class MyLabel
{
    private $properties;

    private $allowedProperties = array('x', 'y', 'text');

    public function __get($name)
    {
        if (isset($properties[$name]) && in_array($name, $this->allowedProperties)) {
            return $properties[$name];
        } else {
            return null;
        }
    }

    public function __set($name, $value)
    {
        if (in_array($name, $this->allowedProperties)) {
            $properties[$name] = $value;
        } else {
            throw new \LogicException("Property $name is not defined.");
        }
    }

}

If the property has read access only, you can use the @property-read annotation instead.

Of course, you may also just have mistyped another name, in which case you should fix the error.

See also the PhpDoc documentation for @property.

Loading history...
646
    }
647
    
648 1
    return null;
649
	}
650
	
651
  /**
652
	 * Return array with all content types title and keys (Use for content-type select) 
653
	 *
654
	 * @Return		Array		$types	Array with the types title and keys
655
	 */
656 1
	public function getTypes(){
657 1
    $types = array();
658
    
659
		// Loop through and save types key as key and title as value in a new array
660 1
		foreach($this->types AS $key => $value){
661 1
			$types[$key] = $value['title'];
662 1
		}
663
		
664 1
		return $types;
665
	}
666
  
667
	/**
668
	 * Return name of one specific type
669
	 *
670
	 * @Params  String $type  Type key
671
	 * @Return  String        Type title
672
	 */
673 1
	public function getTypeTitle($type){
674 1
		return $this->types[$type]['title'];
675
	}
676
  
677
  /**
678
	 * Create a slug of a string, to be used as url.
679
	 *
680
	 * @Param   String   $str  String to format as slug.
681
	 * @Return  String   $str  Formatted slug. 
682
	 */
683 2
	public function slugify($str) {
684 2
	  $str = mb_strtolower(trim($str));
685
		
686 2
		$str = str_replace(array("å","ä","ö"), array("a","a","o"), utf8_decode(utf8_encode($str)));
687
		
688 2
	  $str = preg_replace('/[^a-z0-9-_()]/', '_', $str);
689 2
	  $str = trim(preg_replace('/_+/', '_', $str), '_');
690 2
	  return $str;
691
	}
692
  
693
	/**
694
	 * Check so the choosed type exist.
695
	 *
696
	 * @Param   	String		$type		Choosed type on content
697
	 * @Returns 	Boolean      			Validate result
698
	 */
699 1
	public function checkType($type){
700 1
		return isset($this->types[$type]); 
701
	}
702
  
703
  /**
704
   * Validate posted datetime so it is correct
705
   *
706
   * @Param   String    $datetime      Posted datetime to check  
707
   * @Return  Boolean   True/false     Validate status
708
   */
709
  public function checkDatetime($datetime){
710
    if($datetime){
711
      $format = 'Y-m-d H:i:s';
712
      $d = \DateTime::createFromFormat($format, $datetime);
713
      return $d && $d->format($format) == $datetime;
714
    }
715
    return true;
716
  }
717
  
718
  /**
719
   * Minimum length (set by $this->minimumLength)
720
   *
721
   * @Param   String    $value        Value from form-element to validate
722
   * @Return  Boolean   True/false    Validate result
723
   */
724 1
  public function minimumLength($value){
725 1
    return (strlen($value) >= $this->minimumLength);
726
  }
727
  
728
  /**
729
   * Validate slug url
730
   *
731
   * @Param   String    $url          Url to validate
732
   * @Return  Boolean   True/false    True if valid otherwish false
733
   */
734 1
  public function validateSlug($url){
735 1
    return ($this->slugify($url) == $url);
736
  }
737
  
738
  /**
739
	 * Check so the select filters exist.
740
	 *
741
	 * @Param     Array 	  $filters  Array with select filters
742
	 * @Return    Boolean   $result   Return the result of test
743
	 */
744 1
	public function checkFilter($filter = null){
745 1
	  if(!empty($filter)){
746
      // For each filter, check if the filter exist
747 1
      foreach($this->filters as $val){
748 1
        if($val == $filter)
749 1
          return true;
750 1
      }
751 1
      return false;
752
    }
753 1
	  return true;
754
	}
755
}