Skip to content

Commit

Permalink
removing trailing spaces
Browse files Browse the repository at this point in the history
  • Loading branch information
dogmatic69 committed Jun 20, 2012
1 parent 6dab2ee commit 6f8da8d
Show file tree
Hide file tree
Showing 3 changed files with 75 additions and 75 deletions.
82 changes: 41 additions & 41 deletions Core/Contents/Model/GlobalContent.php
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ class GlobalContent extends ContentsAppModel {
)
),
);

public $findMethods = array(
'contentIssues' => true,
'categoryList' => true,
Expand Down Expand Up @@ -131,22 +131,22 @@ protected function _findContentIssues($state, $query, $results = array()) {
$this->virtualFields['keywords_short'] = '(LENGTH(' . $this->alias . '.meta_keywords) <= 10 AND LENGTH(' . $this->alias . '.meta_keywords) >= 1)';
$this->virtualFields['keywords_duplicate'] = '(GlobalContentDuplicate.id != ' . $this->alias . '.id AND GlobalContentDuplicate.meta_keywords = ' . $this->alias . '.meta_keywords)';
$this->virtualFields['keyword_density_problem'] = '(' . $this->alias . '.keyword_density < 1 OR ' . $this->alias . '.keyword_density > 4)';

$this->virtualFields['description_missing'] = '(' . $this->alias . '.meta_description IS NULL OR ' . $this->alias . '.meta_description)';
$this->virtualFields['description_short'] = '(LENGTH(' . $this->alias . '.meta_description) <= 10 AND LENGTH(' . $this->alias . '.meta_description) >= 1)';
$this->virtualFields['description_duplicate'] = '(GlobalContentDuplicate.id != ' . $this->alias . '.id AND GlobalContentDuplicate.meta_description = ' . $this->alias . '.meta_description)';
$this->virtualFields['description_too_long'] = 'LENGTH(' . $this->alias . '.meta_description) >= 153';

$this->virtualFields['missing_category'] = '(' . $this->alias . '.model <> "Contents.GlobalCategory" AND (' . $this->alias . '.global_category_id IS NULL OR ' . $this->alias . '.global_category_id = ""))';

$this->virtualFields['missing_layout'] = '(' . $this->alias . '.layout_id IS NULL OR ' . $this->alias . '.layout_id = "" )';
$this->virtualFields['missmatched_layout'] = '(Layout.model <> '. $this->alias . '.model)';


$this->virtualFields['introduction_duplicate'] = '(GlobalContentDuplicate.id != ' . $this->alias . '.id AND GlobalContentDuplicate.introduction = ' . $this->alias . '.introduction)';
$this->virtualFields['body_duplicate'] = '(GlobalContentDuplicate.id != ' . $this->alias . '.id AND GlobalContentDuplicate.body = ' . $this->alias . '.body)';
$this->virtualFields['body_word_count'] = 'SUM(LENGTH(' . $this->alias . '.body) - LENGTH(REPLACE(' . $this->alias . '.body, " ", "")) + 1)';

$query['fields'] = array_merge(
(array)$query['fields'],
array(
Expand All @@ -157,7 +157,7 @@ protected function _findContentIssues($state, $query, $results = array()) {
'introduction_duplicate', 'body_duplicate', 'body_word_count'
)
);

$query['joins'][] = array(
'table' => 'global_contents',
'alias' => 'GlobalContentDuplicate',
Expand All @@ -174,8 +174,8 @@ protected function _findContentIssues($state, $query, $results = array()) {
);
if($this->findQueryType != 'count') {
$query['group'] = array(
$this->alias . '.' . $this->primaryKey .' HAVING (' .
$this->alias . '__description_too_long = 1 OR ' .
$this->alias . '.' . $this->primaryKey .' HAVING (' .
$this->alias . '__description_too_long = 1 OR ' .
$this->alias . '__keyword_not_in_description = 1 OR ' .
$this->alias . '__keywords_missing = 1 OR ' .
$this->alias . '__keywords_short = 1 OR ' .
Expand All @@ -193,7 +193,7 @@ protected function _findContentIssues($state, $query, $results = array()) {
$this->alias . '__missmatched_layout = 1 OR ' .
$this->alias . '__introduction_duplicate = 1 OR ' .
$this->alias . '__body_duplicate = 1 OR ' .
$this->alias . '__body_word_count < 300)'
$this->alias . '__body_word_count < 300)'
);
}

Expand Down Expand Up @@ -227,7 +227,7 @@ protected function _findContentIssues($state, $query, $results = array()) {
*/
protected function _findCategoryList($state, $query, $results = array()) {
$this->findQueryType = 'list';

if ($state === 'before') {
$query['conditions'] = array_merge(
(array)$query['conditions'],
Expand All @@ -244,29 +244,29 @@ protected function _findCategoryList($state, $query, $results = array()) {
return $query;
}

$query['list']['groupPath'] = '';
$query['list']['groupPath'] = null;
return $this->_findList($state, $query, $results);
}
protected function _findLatestList($state, $query, $results = array()) {

protected function _findLatestList($state, $query, $results = array()) {
if ($state === 'before') {
$query = $this->__getListQuery($query);
$query['order'] = array($this->alias . '.created' => 'desc');

return $query;
}

return $results;
}
protected function _findPopularList($state, $query, $results = array()) {

protected function _findPopularList($state, $query, $results = array()) {
if ($state === 'before') {
$Model = ClassRegistry::init($query['model']);
$query = $this->__getListQuery($query);
if(!$Model->useTable) {
return $query;
}

$query['joins'][] = array(
'table' => $Model->tablePrefix . $Model->useTable,
'alias' => $Model->alias,
Expand All @@ -275,43 +275,43 @@ protected function _findPopularList($state, $query, $results = array()) {
'GlobalContent.foreign_key = ' . $Model->alias . '.' . $Model->primaryKey
)
);

if($Model->hasField('views')) {
$query['order'] = array($Model->alias. '.views' => 'desc');
}

return $query;
}

return $results;
}
protected function _findSearch($state, $query, $results = array()) {

protected function _findSearch($state, $query, $results = array()) {
if ($state === 'before') {
if(empty($query[0])) {
throw new Exception('No search term defined');
}

$query['conditions'] = array(
sprintf('%s.full_text_search LIKE \'%%%s%%\'', $this->alias, $query[0]),
$this->alias . '.model NOT LIKE' => '%Category%'
);

if(!empty($query[1])) {
$query['conditions']['GlobalCategory.id'] = $query[1];
unset($query[1]);
}

$query['order'] = array(
$this->alias . '.modified' => 'desc',
);

return $query;
}

return $results;
}

private function __getListQuery($query) {
if(!empty($query['model'])) {
$query['conditions'][$this->alias . '.model'] = $query['model'];
Expand All @@ -336,11 +336,11 @@ private function __getListQuery($query) {
);
$query['conditions']['GlobalContentCategoryData.slug'] = $query['category'];
}

unset($query['model'], $query['category']);
return $query;
}

protected function _findGetRelationsCategory($state, $query, $results = array()) {
if ($state === 'before') {
$query['fields'] = array(
Expand Down Expand Up @@ -387,15 +387,15 @@ protected function _findGetRelationsCategory($state, $query, $results = array())
unset($query[0]);
return $query;
}

$return = array();
foreach($results as &$result) {
$result['GlobalContent']['id'] = $result['GlobalContent']['foreign_key'];
$model = $result['GlobalContent']['model'];
unset($result['GlobalContent']['foreign_key'], $result['GlobalContent']['model']);

$return[$model][] = $result['GlobalContent'];

if(!empty($result['SubCategoryData']['id'])) {
$return['Contents.SubCategory'][] = $result['SubCategoryData'];
}
Expand Down Expand Up @@ -430,10 +430,10 @@ public function moveContent($model = null, $limit = 500){
$return = array();
$return['moved'] = 0;

$Model = ClassRegistry::init($model);
$Model = ClassRegistry::init($model);
$return['total'] = $Model->find(
'count',
array(
array(
'conditions' => array(
$Model->alias . '.' . $Model->displayField . ' IS NOT NULL'
)
Expand All @@ -455,7 +455,7 @@ public function moveContent($model = null, $limit = 500){
'limit' => $limit
)
);

foreach($rows as $row){
$newContent = array();
$newContent[$this->alias] = $row[$Model->alias];
Expand All @@ -465,7 +465,7 @@ public function moveContent($model = null, $limit = 500){
if(!isset($newContent[$this->alias]['group_id'])) {
$newContent[$this->alias]['group_id'] = 2;
}

unset($newContent[$this->alias][$Model->primaryKey]);
$this->create();
if($this->save($newContent)){
Expand All @@ -484,7 +484,7 @@ public function moveContent($model = null, $limit = 500){
* @access public
*
* @param int $months the number of months back to look
*
*
* @return array the data found
*/
public function getNewContentByMonth($months = 24) {
Expand Down Expand Up @@ -563,7 +563,7 @@ public function getNewContentByMonth($months = 24) {
}
}
$dates = array_fill_keys(array_keys($dates), 0);

return array(
'labels' => $labels,
'new' => array_merge($dates, $new),
Expand Down
44 changes: 22 additions & 22 deletions Core/Menus/Model/MenuItem.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?php
/**
* The MenuItem model.
*
*
* The MenuItem model handles the items within a menu, these are the indervidual
* links that are used to build up the menu required.
*
Expand All @@ -23,7 +23,7 @@

class MenuItem extends MenusAppModel {
public $useTable = 'menu_items';

/**
* The relations for menu items
* @var array
Expand Down Expand Up @@ -59,7 +59,7 @@ class MenuItem extends MenusAppModel {

public function __construct($id = false, $table = null, $ds = null) {
parent::__construct($id, $table, $ds);

$this->order = array(
$this->alias . '.menu_id' => 'ASC',
$this->alias . '.lft' => 'ASC'
Expand Down Expand Up @@ -145,17 +145,17 @@ public function __construct($id = false, $table = null, $ds = null) {
*
* @param array $field the field being validated
* @access public
*
*
* @return bool is it valid?
*/
public function validateEmptyOrCssClass($field){
$field = current($field);
if(empty($field) && $field !== 0) {
return true;
}

preg_match('/-?[_a-zA-Z]+[_a-zA-Z0-9-]*/', $field, $matches);

return current($matches) === $field;
}

Expand All @@ -171,7 +171,7 @@ public function validateEmptyOrCssClass($field){
*/
public function beforeValidate($options = array()){
$foreignKey = $this->belongsTo[$this->Menu->alias]['foreignKey'];

if(!empty($this->data[$this->alias][$foreignKey]) && empty($this->data[$this->alias]['parent_id'])) {
$menuItem = $this->find(
'first',
Expand All @@ -185,11 +185,11 @@ public function beforeValidate($options = array()){
)
)
);

if(empty($menuItem[$this->alias]['id'])) {
return false;
}

$this->data[$this->alias]['parent_id'] = $menuItem[$this->alias]['id'];
}

Expand Down Expand Up @@ -219,7 +219,7 @@ public function getMenu($type = null){
$menus = $this->find(
'threaded',
array(
'fields' => array(
'fields' => array(
$this->alias . '.id',
$this->alias . '.name',
$this->alias . '.link',
Expand Down Expand Up @@ -262,7 +262,7 @@ public function getMenu($type = null){
)
)
);

foreach($menus as &$menu) {
$this->__underscore($menu);
}
Expand All @@ -271,16 +271,16 @@ public function getMenu($type = null){

return $menus;
}

/**
* convert the camelcase stuff to underscored so links work properly
*
*
* @param array $menu the row of menu data
*/
private function __underscore(&$menu) {
$menu[$this->alias]['plugin'] = Inflector::underscore($menu[$this->alias]['plugin']);
$menu[$this->alias]['controller'] = substr(Inflector::underscore($menu[$this->alias]['controller']), 0, -11);

if(!empty($menu['children'])) {
foreach($menu['children'] as &$child) {
$this->__underscore($child);
Expand Down Expand Up @@ -309,7 +309,7 @@ public function hasContainer($menuId, $name = null) {
)
)
);

if($count > 0){
return true;
}
Expand All @@ -328,23 +328,23 @@ public function hasContainer($menuId, $name = null) {
$this->create();
return (bool)$this->save($data, array('validate' => false));
}

/**
* @brief get the menus for the ajax select in the backend
*
*
* @access public
*
* @throws Exception
*
*
* @throws Exception
*
* @param string $menuId the menu to look up
*
*
* @return array
*/
public function getParents($menuId = null) {
if(!$menuId) {
throw new Exception('No menu selected');
}

return $this->generateTreeList(array('MenuItem.menu_id' => $menuId));
}
}

0 comments on commit 6f8da8d

Please sign in to comment.