Changeset 3605ef4cbbdb0bce13d7f8f2d89564bdce062ab1

Show
Ignore:
Timestamp:
01/15/12 14:59:03 (4 months ago)
Author:
Xemle <xemle@phtagr.org>
Children:
28879c66921dd6a95bea71bfa032508c45bc6467
Parents:
e449ecc0f26cb90b41ca32d98ed3f37f762c9f5a
git-committer:
Xemle <xemle@phtagr.org> / 2012-01-15T14:59:03Z+0100
Message:

Migrate code for CakePHP 2.0

Files:
36 modified
2 moved

Legend:

Unmodified
Added
Removed
  • Controller/AppController.php

    re449ecc0 r3605ef4  
    4949  function _setMainMenu() { 
    5050    $this->Menu->setCurrentMenu('main-menu'); 
    51     $this->Menu->addItem(__('Home', true), "/"); 
    52     $this->Menu->addItem(__('Explorer', true), array('controller' => 'explorer')); 
     51    $this->Menu->addItem(__('Home'), "/"); 
     52    $this->Menu->addItem(__('Explorer'), array('controller' => 'explorer')); 
    5353    if ($this->hasRole(ROLE_GUEST)) { 
    5454      $user = $this->getUser(); 
    55       $this->Menu->addItem(__('My Photos', true), array('controller' => 'explorer', 'action' => 'user', $user['User']['username'])); 
     55      $this->Menu->addItem(__('My Photos'), array('controller' => 'explorer', 'action' => 'user', $user['User']['username'])); 
    5656    } 
    5757    if ($this->hasRole(ROLE_USER)) { 
    58       $this->Menu->addItem(__('Upload', true), array('controller' => 'browser', 'action' => 'quickupload')); 
     58      $this->Menu->addItem(__('Upload'), array('controller' => 'browser', 'action' => 'quickupload')); 
    5959    } 
    6060  } 
     
    6464    $role = $this->getUserRole(); 
    6565    if ($role == ROLE_NOBODY) { 
    66       $this->Menu->addItem(__('Login', true), array('controller' => 'users', 'action' => 'login')); 
     66      $this->Menu->addItem(__('Login'), array('controller' => 'users', 'action' => 'login')); 
    6767      if ($this->getOption('user.register.enable', 0)) { 
    68         $this->Menu->addItem(__('Sign Up', true), array('controller' => 'users', 'action' => 'register')); 
     68        $this->Menu->addItem(__('Sign Up'), array('controller' => 'users', 'action' => 'register')); 
    6969      } 
    7070    } else { 
    7171      $user = $this->getUser(); 
    72       $this->Menu->addItem(sprintf(__('Howdy, %s!', true), $user['User']['username']), false); 
    73       $this->Menu->addItem(__('Logout', true), array('controller' => 'users', 'action' => 'logout')); 
    74       $this->Menu->addItem(__('Dashboard', true), array('controller' => 'options')); 
     72      $this->Menu->addItem(__('Howdy, %s!', $user['User']['username']), false); 
     73      $this->Menu->addItem(__('Logout'), array('controller' => 'users', 'action' => 'logout')); 
     74      $this->Menu->addItem(__('Dashboard'), array('controller' => 'options')); 
    7575    } 
    7676  } 
     
    144144   * @todo Check expired user */ 
    145145  function _checkSession() { 
    146     $this->Session->activate(); 
     146    //$this->Session->activate(); 
    147147    if (!$this->Session->check('Session.requestCount')) { 
    148148      $this->Session->write('Session.requestCount', 1); 
     
    280280      $parent->components[] = $componentName; 
    281281    } 
    282     $this->Component->_loadComponents($parent); 
    283     $this->Component->initialize($this); 
    284  
    285     if (isset($parent->{$componentName})) { 
    286       return true; 
    287     } else { 
     282    $component = $this->Components->load($componentName); 
     283    if (!$component) { 
    288284      Logger::warn("Could not load component $componentName"); 
    289285      return false; 
    290286    } 
     287    $parent->{$componentName} = $component; 
     288    $component->initialize(&$this); 
     289 
     290    return true; 
    291291  } 
    292292  
  • Controller/BrowserController.php

    r6aa1330 r3605ef4  
    356356      // clear file cache  
    357357      @clearstatcache(); 
    358       $start = $now = getMicrotime(); 
     358      $start = $now = microtime(true); 
    359359      $executionTime = ini_get('max_execution_time') - 5; 
    360360 
     
    369369          } 
    370370 
    371           $now = getMicrotime(); 
     371          $now = microtime(true); 
    372372          if ($now - $start > $executionTime) { 
    373373            break; 
  • Controller/Component/BaseFilterComponent.php

    re449ecc0 r3605ef4  
    2222 */ 
    2323 
    24 class BaseFilterComponent extends Object { 
     24class BaseFilterComponent extends Component { 
    2525 
    2626  var $components = array(); 
  • Controller/Component/CaptchaComponent.php

    re449ecc0 r3605ef4  
    11<?php  
    2 App::import('vendor', 'kcaptcha'); 
    3 class CaptchaComponent extends Object 
     2App::uses('vendor', 'kcaptcha'); 
     3class CaptchaComponent extends Component 
    44{ 
    55  function initialize(&$controller) { 
  • Controller/Component/CommandComponent.php

    re449ecc0 r3605ef4  
    2222 */ 
    2323 
    24 class CommandComponent extends Object { 
     24class CommandComponent extends Component { 
    2525 
    2626  var $controller = null; 
     
    6060      $this->lastCommand .= ' 2>&1'; 
    6161    } 
    62     $t1 = getMicrotime(); 
     62    $t1 = microtime(true); 
    6363    exec($this->lastCommand, &$output, &$result); 
    64     $t2 = getMicrotime(); 
     64    $t2 = microtime(true); 
    6565    $this->output = $output; 
    6666    Logger::debug("Command '{$this->lastCommand}' returned $result and required ".round($t2-$t1, 4)."ms"); 
  • Controller/Component/FastFileResponderComponent.php

    re449ecc0 r3605ef4  
    2222 */ 
    2323 
    24 class FastFileResponderComponent extends Object { 
     24class FastFileResponderComponent extends Component { 
    2525  var $controller = null; 
    2626  var $components = array('Session', 'FileCache'); 
  • Controller/Component/FeedComponent.php

    re449ecc0 r3605ef4  
    2222 */ 
    2323 
    24 class FeedComponent extends Object { 
     24class FeedComponent extends Component { 
    2525   
    2626  var $name = 'FeedComponent'; 
    27  
     27   
    2828  var $controller = null; 
    2929 
     
    4141  /** Set feeds output for layout */ 
    4242  function beforeRender() { 
    43     App::import('Helper', 'Html'); 
    44     $html = new HtmlHelper(); 
    45  
     43    App::uses('HtmlHelper', 'View/Helper'); 
     44    App::uses('View', 'View'); 
     45    $View = new View($this->controller, false); 
     46    $Html = new HtmlHelper($View); 
    4647    $output = ''; 
    4748    foreach($this->_feeds as $url => $options) { 
     
    5657        unset($options['url']); 
    5758      } 
    58       $output .= $html->meta($type, $url, $options); 
     59      $output .= $Html->meta($type, $url, $options); 
    5960    } 
    6061    $this->controller->set('feeds_for_layout', $output); 
  • Controller/Component/FileCacheComponent.php

    re449ecc0 r3605ef4  
    2222 */ 
    2323 
    24 class FileCacheComponent extends Object { 
     24App::uses('Folder', 'Utility'); 
     25 
     26class FileCacheComponent extends Component { 
    2527 
    2628  var $controller = null; 
  • Controller/Component/FileManagerComponent.php

    re449ecc0 r3605ef4  
    2222 */ 
    2323 
    24 class FileManagerComponent extends Object { 
     24class FileManagerComponent extends Component { 
    2525 
    2626  var $controller = null; 
  • Controller/Component/FilterManagerComponent.php

    re449ecc0 r3605ef4  
    2222 */ 
    2323 
    24 class FilterManagerComponent extends Object { 
     24class FilterManagerComponent extends Component { 
    2525 
    2626  var $controller = null; 
     
    5151      return false; 
    5252    } 
    53     $this->MyFile =& $controller->MyFile; 
    54     $this->Media =& $controller->Media; 
    5553    $this->loadFilter(array('ImageFilter', 'SimpleImageFilter', 'VideoFilter', 'GpsFilter')); 
    5654  } 
     
    7674      return true; 
    7775    } 
    78     $filter->MyFile =& $this->MyFile; 
    79     $filter->Media =& $this->Media; 
    80     $filter->FilterManager =& $this; 
     76    $filter->FilterManager = $this; 
    8177 
    8278    $filter->init(&$this); 
  • Controller/Component/ImageResizerComponent.php

    re449ecc0 r3605ef4  
    2121 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA. 
    2222 */ 
    23 if (!App::import('Vendor', "phpthumb", true, array(), "phpthumb.class.php")) { 
     23if (!class_exists('phpThumb') && !App::import('Vendor', "phpthumb", true, array(), "phpthumb/phpthumb.class.php")) { 
    2424  debug("Please install phpthumb properly"); 
    2525} 
    2626 
    27 class ImageResizerComponent extends Object { 
     27class ImageResizerComponent extends Component { 
    2828 
    2929  var $controller = null; 
     
    9696    } 
    9797 
    98     $t0 = getMicrotime(); 
     98    $t0 = microtime(true); 
    9999    if ($this->_semaphoreId) { 
    100100      sem_acquire($this->_semaphoreId); 
    101101    } 
    102     $t1 = getMicrotime(); 
     102    $t1 = microtime(true); 
    103103    $result = $phpThumb->GenerateThumbnail(); 
    104     $t2 = getMicrotime(); 
     104    $t2 = microtime(true); 
    105105    if ($this->_semaphoreId) { 
    106106      sem_release($this->_semaphoreId); 
  • Controller/Component/MenuComponent.php

    re449ecc0 r3605ef4  
    2222 */ 
    2323 
    24 class MenuComponent extends Object { 
     24class MenuComponent extends Component { 
    2525 
    2626        var $components = array('Session'); 
  • Controller/Component/PreviewManagerComponent.php

    re449ecc0 r3605ef4  
    2222 */ 
    2323 
    24 class PreviewManagerComponent extends Object { 
     24class PreviewManagerComponent extends Component { 
    2525 
    2626  var $controller = null; 
     
    6363  function initialize(&$controller) { 
    6464    $this->controller =& $controller; 
    65     if (!isset($controller->MyFile) || !isset($controller->Media)) { 
     65    if (!isset($controller->Media)) { 
    6666      Logger::err("Model MyFile and Media is not found"); 
    6767      return false; 
    6868    } 
    69     $this->MyFile =& $controller->MyFile; 
    70     $this->Media =& $controller->Media; 
    7169  } 
    7270 
    7371  /** Return image source file of the media */ 
    7472  function _getImageSoureFilename($media) { 
    75     $type = $this->Media->getType($media); 
     73    $type = $this->controller->Media->getType($media); 
    7674    if ($type != MEDIA_TYPE_IMAGE && $type != MEDIA_TYPE_VIDEO) { 
    77       Logger::err("Media type not supported: {$this->Media->getType($media)}"); 
     75      Logger::err("Media type not supported: {$this->controller->Media->getType($media)}"); 
    7876      return false; 
    7977    }  
     
    8280      return $this->VideoPreview->getPreviewFilename($media); 
    8381    }  
    84     $file = $this->Media->getFile($media, FILE_TYPE_IMAGE, false); 
     82    $file = $this->controller->Media->getFile($media, FILE_TYPE_IMAGE, false); 
    8583    if (!$file) { 
    8684      Logger::err("No files are attached to media {$media['Media']['id']}"); 
    8785      return false; 
    8886    } 
    89     return $this->Media->File->getFilename($file); 
     87    return $this->controller->Media->File->getFilename($file); 
    9088  } 
    9189 
     
    109107      $src = $this->_getImageSoureFilename($media); 
    110108      $config['clearMetaData'] = true; 
    111       $config['rotation'] = $this->Media->getRotationInDegree($media); 
     109      $config['rotation'] = $this->controller->Media->getRotationInDegree($media); 
    112110    } 
    113111    $dst = $this->FileCache->getFilePath($media, $name); 
    114112    if (!$dst) { 
    115       Logger::err("Could not get cache file path for media {$this->Media->toString($media)}"); 
     113      Logger::err("Could not get cache file path for media {$this->controller->Media->toString($media)}"); 
    116114      return false; 
    117115    } 
  • Controller/Component/QueryBuilderComponent.php

    re449ecc0 r3605ef4  
    2222 */ 
    2323 
    24 App::import('Core', array('Sanitize')); 
    25  
    26 class QueryBuilderComponent extends Object 
     24App::uses('Sanitize', 'Utility'); 
     25 
     26class QueryBuilderComponent extends Component 
    2727{ 
    28   var $components = array(); 
    29  
    3028  var $controller = null; 
    3129 
     
    5755  function initialize(&$controller) { 
    5856    $this->controller = &$controller; 
    59     $this->Sanitize =& new Sanitize(); 
     57    $this->Sanitize = new Sanitize(); 
    6058  } 
    6159 
  • Controller/Component/SearchComponent.php

    re449ecc0 r3605ef4  
    2222 */ 
    2323 
    24 App::import('Core', array('Validation')); 
    25 App::import('File', 'Search', array('file' => APP.'search.php')); 
    26  
    27 class SearchComponent extends Search 
     24if (!App::uses('Validation', 'Utility')) { 
     25  CakeLog::write('error', 'Could not load validation'); 
     26} 
     27if (!class_exists('Search')) { 
     28  App::import('File', 'Search', array('file' => APP.'search.php')); 
     29} 
     30 
     31class SearchComponent extends Component 
    2832{ 
    2933  var $components = array('QueryBuilder'); 
    3034 
    3135  var $controller = null; 
    32  
    33   var $Validation = null; 
     36   
     37  var $_data; 
    3438 
    3539  /** Parameter validation array 
     
    8286  function initialize(&$controller) { 
    8387    $this->controller = &$controller; 
    84     $this->Validation =& Validation::getInstance(); 
     88    if (!$this->QueryBuilder->controller) { 
     89      $this->QueryBuilder->initialize(&$controller); 
     90    } 
    8591    $this->clear(); 
     92    return true; 
    8693  } 
    8794 
    8895  function clear() { 
    8996    $this->_data = $this->defaults; 
     97  } 
     98 
     99  /** Returns all parameters  
     100    @return Parameter array */ 
     101  function getParams() { 
     102    return $this->_data; 
     103  } 
     104 
     105  /** Set all parameters  
     106    @param data Parameter array 
     107    @note The parameters are not validated! */ 
     108  function setParams($data = array()) { 
     109    $this->_data = $data; 
     110  } 
     111 
     112  /** Returns parameter  
     113    @param name Name of parameter  
     114    @param default Default value, if the parameter does not exists. Default 
     115    value is null */ 
     116  function getParam($name, $default = null) { 
     117    if (!empty($this->_data[$name])) { 
     118      return $this->_data[$name]; 
     119    } else { 
     120      return $default; 
     121    } 
     122  } 
     123 
     124  /** Set a singular parameter  
     125    @param name Parameter name 
     126    @param value Parameter value 
     127    @param validate Optional parameter to validate the parameter. Default is 
     128    true 
     129    @return True on success */ 
     130  function setParam($name, $value, $validate = true) { 
     131    if ($validate === false || $this->validate($name, $value)) { 
     132      $this->_data[$name] = $value; 
     133      return true; 
     134    } else { 
     135      return false; 
     136    } 
     137  } 
     138 
     139  /** Add a parameter to an array. 
     140    @param name Parameter name.  
     141    @param value Parameter value (which will be pluralized) 
     142    @param validate Optional parameter to validate the parameter. Default is 
     143    true 
     144    @note The name will be pluralized. */ 
     145  function addParam($name, $value, $validate = true) { 
     146    $name = Inflector::pluralize($name); 
     147    if (is_array($value)) { 
     148      foreach ($value as $v) { 
     149        $this->addParam($name, $v, $validate); 
     150      } 
     151      return; 
     152    } 
     153     
     154    if ((!isset($this->_data[$name]) || !in_array($value, $this->_data[$name])) && 
     155      ($validate === false || $this->validate($name, $value))) { 
     156      $this->_data[$name][] = $value; 
     157    } 
     158  } 
     159 
     160  function delParam($name, $value = false) { 
     161    if (!isset($this->_data[$name])) { 
     162      return; 
     163    } 
     164     
     165    if (!empty($value)) { 
     166      if (is_array($value)) { 
     167        foreach ($value as $v) { 
     168          $this->delParam($name, $v); 
     169        } 
     170        return; 
     171      } 
     172      // handle array 
     173      $key = array_search($value, $this->_data[$name]); 
     174      if ($key !== false) { 
     175        unset($this->_data[$name][$key]); 
     176      } 
     177      if (count($this->_data[$name]) == 0) { 
     178        unset($this->_data[$name]); 
     179      } 
     180    } else { 
     181      // handle single value 
     182      unset($this->_data[$name]); 
     183    } 
     184  } 
     185 
     186  function __call($name, $args) { 
     187    if (!preg_match('/^(get|set|add|del|delete)(.*)$/', $name, $matches)) { 
     188      $this->log("Undefined function $name"); 
     189      return; 
     190    } 
     191    $name = Inflector::underscore($matches[2]); 
     192    switch ($matches[1]) { 
     193      case 'get': 
     194        if (count($args) > 0) { 
     195          return $this->getParam($name, $args[0]); 
     196        } else { 
     197          return $this->getParam($name); 
     198        } 
     199        break; 
     200      case 'set': 
     201        if (count($args) == 1) { 
     202          return $this->setParam($name, $args[0]); 
     203        } elseif (count($args) == 2) { 
     204          return $this->setParam($name, $args[0], $args[1]); 
     205        } 
     206        break; 
     207      case 'add': 
     208        if (count($args) == 1) { 
     209          return $this->addParam($name, $args[0]); 
     210        } elseif (count($args) == 2) { 
     211          return $this->addParam($name, $args[0], $args[1]); 
     212        } 
     213        break; 
     214      case 'del': 
     215      case 'delete': 
     216        if (count($args) == 1) { 
     217          if (!isset($this->_data[$name])) { 
     218            $plural = Inflector::pluralize($name); 
     219            if (isset($this->_data[$plural])) { 
     220              $name = $plural; 
     221            } 
     222          } 
     223          $this->delParam($name, $args[0]); 
     224        } else { 
     225          $this->delParam($name); 
     226        } 
     227        break; 
     228    } 
    90229  } 
    91230 
     
    156295    if (method_exists(&$this, $rule)) { 
    157296      $result = $this->dispatchMethod($rule, $params); 
    158     } elseif (method_exists(&$this->Validation, $rule)) { 
    159       $result = $this->Validation->dispatchMethod($rule, $params); 
     297    } elseif (method_exists('Validation', $rule)) { 
     298      $result = call_user_func_array(array('Validation', $rule), $params); 
    160299    } else { 
    161300      Logger::debug("Rule '$rule' could not be found"); 
  • Controller/Component/UpgradeSchemaComponent.php

    re449ecc0 r3605ef4  
    2222 */ 
    2323 
    24 class UpgradeSchemaComponent extends Object{ 
     24class UpgradeSchemaComponent extends Component { 
    2525 
    2626  var $controller = null; 
     
    4242    } 
    4343 
    44     App::import('Core', 'ConnectionManager'); 
     44    App::uses('ConnectionManager', 'Model'); 
    4545    $this->db =& ConnectionManager::getDataSource('default'); 
    4646    if (!$this->db) { 
  • Controller/Component/UploadComponent.php

    re449ecc0 r3605ef4  
    2222 */ 
    2323 
    24 class UploadComponent extends Object { 
     24class UploadComponent extends Component { 
    2525   
    2626  var $name = 'UploadComponent'; 
  • Controller/Component/VideoPreviewComponent.php

    re449ecc0 r3605ef4  
    2222 */ 
    2323 
    24 class VideoPreviewComponent extends Object { 
     24class VideoPreviewComponent extends Component { 
    2525 
    2626  var $controller = null; 
  • Controller/Component/ZipComponent.php

    re449ecc0 r3605ef4  
    2222 */ 
    2323 
    24 class ZipComponent extends Object { 
     24App::uses('Folder', 'Utility'); 
     25 
     26class ZipComponent extends Component { 
    2527   
    2628  var $name = 'ZipComponent'; 
  • Controller/HomeController.php

    re449ecc0 r3605ef4  
    3737    } 
    3838 
    39     App::import('Core', 'ConnectionManager'); 
     39    App::uses('ConnectionManager', 'Model'); 
    4040    $db =& ConnectionManager::getDataSource('default'); 
    41     if (empty($db->connection)) { 
     41    if (!$db->enabled()) { 
    4242      $this->redirect('/setup'); 
    4343    } 
  • Controller/MediaController.php

    re449ecc0 r3605ef4  
    2121 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA. 
    2222 */ 
    23 if (!App::import('Vendor', "phpthumb", true, array(), "phpthumb.class.php")) { 
    24   debug("Please install phpthumb properly"); 
    25 } 
    26  
    2723class MediaController extends AppController 
    2824{ 
    2925  var $name = 'Media'; 
    30   var $uses = array('Media', 'MyFile'); 
     26  var $uses = array('User', 'Media', 'MyFile'); 
    3127  var $layout = null; 
    3228  var $config = array( 
     
    4945   
    5046  function beforeRender() { 
    51     parent::beforeFilter(); 
    52     $this->view = 'Media'; 
     47    parent::beforeRender(); 
     48    $this->viewClass = 'Media'; 
    5349  } 
    5450 
     
    110106    } 
    111107    $conditions = $this->Media->buildAclConditions($user, 0, $flag); 
    112     $conditions[] = "Media.id = $id"; 
    113     $media = $this->Media->find($conditions); 
     108    $conditions[] = 'Media.id = ' . $id; 
     109    $media = $this->Media->find('first', array('conditions' => $conditions)); 
    114110    if (!$media) { 
    115111      Logger::verbose("Media not found or access denied for media $id"); 
     
    130126 
    131127    $this->set($this->MyFile->getMediaViewOptions($preview)); 
    132     $this->view = 'Media'; 
     128    $this->viewClass = 'Media'; 
    133129  } 
    134130 
     
    175171    $mediaOptions = $this->MyFile->getMediaViewOptions($filename); 
    176172    $mediaOptions['download'] = true; 
    177     $this->view = 'Media'; 
     173    $this->viewClass = 'Media'; 
    178174    $this->set($mediaOptions); 
    179175  } 
     
    201197    $mediaOptions = $this->MyFile->getMediaViewOptions($filename); 
    202198    $mediaOptions['download'] = true; 
    203     $this->view = 'Media'; 
     199    $this->viewClass = 'Media'; 
    204200    $this->set($mediaOptions); 
    205201  } 
  • Controller/SetupController.php

    re449ecc0 r3605ef4  
    292292    $max = strlen($chars) - 1; 
    293293 
    294     srand(getMicrotime()*1000); 
     294    srand(microtime(true)*1000); 
    295295    $salt = ''; 
    296296    for($i = 0; $i < 40; $i++) { 
  • Model/AppModel.php

    re449ecc0 r3605ef4  
    233233      if (isset($data[$name])) { 
    234234        return $data[$name]; 
    235       } else { 
    236         return null; 
    237       } 
    238     } 
     235      } 
     236    } 
     237    return parent::__get($name); 
    239238  } 
    240239 
  • Model/Behavior/CipherBehavior.php

    re449ecc0 r3605ef4  
    167167    @return Randomly generated salt of the given lenth */ 
    168168  function _generateSalt($value, $key = '9nHPrYcxmvTliA', $len = 4) { 
    169     srand(getMicrotime()*1000); 
     169    srand(microtime(true)*1000); 
    170170    $salt = ''; 
    171171    $lenKey = strlen($key); 
  • Model/Guest.php

    r7f46ca8 r3605ef4  
    9494 
    9595  function generateKey($data) { 
    96     srand(getMicrotime()*1000); 
     96    srand(microtime(true)*1000); 
    9797    $h = ''; 
    9898    for ($i = 0; $i < 128; $i++) { 
  • Model/Media.php

    re449ecc0 r3605ef4  
    241241    } 
    242242 
    243     $data['Media']['isOwner'] = ife($data['Media']['user_id'] == $user['User']['id'], true, false); 
     243    $data['Media']['isOwner'] = ($data['Media']['user_id'] == $user['User']['id']) ? true : false; 
    244244    $data['Media']['canWriteAcl'] = $this->checkAccess(&$data, &$user, 1, 0, &$groups);     
    245     $data['Media']['isDirty'] = ife(($data['Media']['flag'] & MEDIA_FLAG_DIRTY) > 0, true, false); 
     245    $data['Media']['isDirty'] = (($data['Media']['flag'] & MEDIA_FLAG_DIRTY) > 0) ? true : false; 
    246246 
    247247    return $data; 
  • Model/User.php

    re449ecc0 r3605ef4  
    205205    @return User model data */ 
    206206  function generateKey($data, $length = 10, $alphabet = false) { 
    207     srand(getMicrotime()*1000); 
     207    srand(microtime(true)*1000); 
    208208 
    209209    if (!$alphabet || strlen(strval($alphabet)) < 10) { 
  • View/Browser/index.ctp

    re449ecc0 r3605ef4  
    1 <h1><?php __('File Browser'); ?></h1> 
     1<h1><?php echo __('File Browser'); ?></h1> 
    22 
    3 <?php echo $session->flash(); ?> 
     3<?php echo $this->Session->flash(); ?> 
    44 
    5 <?php echo $form->create('Browser', array('action' => 'import/'.$path)); ?> 
     5<?php echo $this->Form->create('Browser', array('action' => 'import/'.$path)); ?> 
    66 
    7 <p><?php printf(__("Location %s", true), $fileList->location($path)); ?> 
     7<p><?php echo __("Location %s", $this->FileList->location($path)); ?> 
    88<?php if ($isInternal) { 
    9   printf(__(" (%s or %s here)", true),  
    10     $html->link(__("Upload files", true), 'upload/'.$path), 
    11     $html->link(__("create folder", true), 'folder/'.$path)); 
     9  echo __(" (%s or %s here)",  
     10    $this->Html->link(__("Upload files"), 'upload/'.$path), 
     11    $this->Html->link(__("create folder"), 'folder/'.$path)); 
    1212  } ?>.  
    1313 
    14 <?php echo $fileList->table($path, $dirs, $files, array('isInternal' => $isInternal)); ?> 
     14<?php echo $this->FileList->table($path, $dirs, $files, array('isInternal' => $isInternal)); ?> 
    1515 
    16 <p><?php printf(__("Location %s", true), $fileList->location($path)); ?> 
     16<p><?php echo __("Location %s", $this->FileList->location($path)); ?> 
    1717<?php if ($isInternal) { 
    18   printf(__(" (%s or %s here)", true),  
    19     $html->link(__("Upload files", true), 'upload/'.$path), 
    20     $html->link(__("create folder", true), 'folder/'.$path)); 
     18  echo __(" (%s or %s here)",  
     19    $this->Html->link(__("Upload files"), 'upload/'.$path), 
     20    $this->Html->link(__("create folder"), 'folder/'.$path)); 
    2121  } ?>.  
    2222</p> 
    2323 
    2424<?php  
    25   echo $form->submit(__('Import', true)); 
    26   echo $form->end(); 
     25  echo $this->Form->submit(__('Import')); 
     26  echo $this->Form->end(); 
    2727?> 
  • View/Browser/sync.ctp

    re449ecc0 r3605ef4  
    1 <h1><?php __("Meta Data Synchronization"); ?></h1> 
     1<h1><?php echo __("Meta Data Synchronization"); ?></h1> 
    22 
    3 <?php echo $session->flash(); ?> 
     3<?php echo $this->Session->flash(); ?> 
    44 
    5 <p><?php __("phTagr embedds meta data like tags, categories, or (geo) location information direct into the image video files."); ?></p> 
     5<p><?php echo __("phTagr embedds meta data like tags, categories, or (geo) location information direct into the image video files."); ?></p> 
    66 
    7 <p><?php __("Note:  In case you are using phTagr with external paths it is recommended to synchronize your images to store this important information within the media file.  After the synchronization these mata data could be read by other image programs or desktop search engines."); ?> 
     7<p><?php echo __("Note:  In case you are using phTagr with external paths it is recommended to synchronize your images to store this important information within the media file.  After the synchronization these mata data could be read by other image programs or desktop search engines."); ?> 
    88 
    99<?php if ($this->data['action'] != 'run' && $this->data['unsynced'] > 0): ?> 
    10 <p><?php printf(__("You have %d unsynchronized media. Click %s to start the synchronization (this might take some time)", true), $this->data['unsynced'], $html->link(__("sync", true), 'sync/run')); ?></p> 
     10<p><?php echo __("You have %d unsynchronized media. Click %s to start the synchronization (this might take some time)", $this->data['unsynced'], $this->Html->link(__("sync", true), 'sync/run')); ?></p> 
    1111<?php endif; ?> 
    1212 
    1313<?php if ($this->data['unsynced'] == 0): ?> 
    14 <div class="info"><?php __("All media are synchronized"); ?></div> 
     14<div class="info"><?php echo __("All media are synchronized"); ?></div> 
    1515<?php endif; ?> 
    1616 
    1717<?php if (count($this->data['errors'])): ?> 
    18 <div class="error"><?php __("Some files could not be updated with new metadata. Mainly this happens if the files are write protected. Please have a look to the log files for details."); ?></div> 
     18<div class="error"><?php echo __("Some files could not be updated with new metadata. Mainly this happens if the files are write protected. Please have a look to the log files for details."); ?></div> 
    1919<?php endif; ?> 
    2020 
    2121<?php if ($this->data['action'] == 'run'): ?> 
    2222<p><?php  
    23   printf(__("Synchronized %d media.", true), count($this->data['synced'])); 
     23  echo __("Synchronized %d media.", count($this->data['synced'])); 
    2424  if ($this->data['unsynced']) { 
    25     printf(__(" %d media remains unsynced. Click %s to synchronize again", true), $this->data['unsynced'], $html->link(__('sync', true), 'sync/run'));  
     25    echo __(" %d media remains unsynced. Click %s to synchronize again", $this->data['unsynced'], $this->Html->link(__('sync', 'sync/run')));  
    2626  } 
    2727?></p> 
  • View/Elements/topnav.ctp

    re449ecc0 r3605ef4  
    55    $name = $session->read('User.username'); 
    66    if ($role >= ROLE_SYSOP) { 
    7       echo $html->link(__('System', true), "/admin/system/general")." | "; 
     7      echo $html->link(__('System'), "/admin/system/general")." | "; 
    88    } 
    99    if ($role >= ROLE_USER) { 
    10       echo $html->link(__('Preferences', true), "/options/profile")." | "; 
     10      echo $html->link(__('Preferences'), "/options/profile")." | "; 
    1111    } 
    12     echo $html->link(__("Logout", true), "/users/logout"). " ($name)"; 
     12    echo $html->link(__("Logout"), "/users/logout"). " ($name)"; 
    1313  } else { 
    14     echo $html->link(__("Login", true), "/users/login"); 
     14    echo $html->link(__("Login"), "/users/login"); 
    1515    if ($option->get('user.register.enable', 0)) { 
    1616      echo ' | '.$html->link(__("Register", true), "/users/register"); 
  • View/Helper/FileListHelper.php

    re449ecc0 r3605ef4  
    8080    $actions = array(); 
    8181    if ($options['isInternal']) { 
    82       $actions[] = $this->Html->link('delete', "delete/$path", array('style' => 'color: red', 'onclick' => "return confirm('" . sprintf(__('Delete folder %s?', true), $path) . "')")); 
     82      $actions[] = $this->Html->link('delete', "delete/$path", array('style' => 'color: red', 'onclick' => "return confirm('" . __('Delete folder %s?', $path) . "')")); 
    8383    } 
    8484    $row[] = implode('', $actions); 
     
    9393    if (isset($file['media_id'])) { 
    9494      $mediaLink = $this->Html->link($file['media_id'], '/images/view/'.$file['media_id']); 
    95       $unlink = $this->Html->link('unlink', "unlink/$path/{$file['file']}", array('style' => 'color: red', 'title' => __('Unlink media from this file', true))); 
     95      $unlink = $this->Html->link('unlink', "unlink/$path/{$file['file']}", array('style' => 'color: red', 'title' => __('Unlink media from this file'))); 
    9696      $row[] = $mediaLink.' '.$unlink; 
    9797    } else { 
     
    103103    // Download link for internal files and imported external files 
    104104    if ($options['isInternal'] || $file['media_id'] > 0) { 
    105       $icon = $this->Html->image('icons/disk.png', array('alt' => 'download', 'title' => sprintf(__('Download %s', true), $file['file']))); 
     105      $icon = $this->Html->image('icons/disk.png', array('alt' => 'download', 'title' => __('Download %s', $file['file']))); 
    106106      $actions[] = $this->Html->link($icon, "index/$path/{$file['file']}", array('escape' => false)); 
    107107    } 
     
    121121    if ($path != '/') { 
    122122      $parentPath = dirname($path); 
    123       $cells[] = $this->_dirRow($parentPath, __('(parent folder)', true), array('checkBox' => false, 'isInternal' => false)); 
     123      $cells[] = $this->_dirRow($parentPath, __('(parent folder)'), array('checkBox' => false, 'isInternal' => false)); 
    124124    } 
    125     $cells[] = $this->_dirRow($path, __('(this folder)', true), $options); 
     125    $cells[] = $this->_dirRow($path, __('(this folder)'), $options); 
    126126    usort($dirs, array("FileListHelper", "_cmpFile")); 
    127127    usort($files, array("FileListHelper", "_cmpFile")); 
     
    135135    $out .= "<thead>\n"; 
    136136    $out .= $this->Html->tableHeaders( 
    137       array('', __('Name', true), __('Media', true), __('Size', true), __('Actions', true)) 
     137      array('', __('Name'), __('Media'), __('Size'), __('Actions')) 
    138138      ); 
    139139    $out .= "</thead>\n"; 
  • View/Helper/ImageDataHelper.php

    re449ecc0 r3605ef4  
    2222 */ 
    2323     
    24 App::import('Core', 'Sanitize'); 
     24App::uses('Sanitize', 'Utility'); 
    2525 
    2626class ImageDataHelper extends AppHelper { 
  • View/Helper/SearchHelper.php

    re449ecc0 r3605ef4  
    2222 */ 
    2323 
    24 App::import('File', 'Search', array('file' => APP.'search.php')); 
     24if (!class_exists('Search')) { 
     25  App::import('File', 'Search', array('file' => APP.'search.php')); 
     26} 
    2527 
    2628class SearchHelper extends Search { 
  • View/Layouts/backend.ctp

    re449ecc0 r3605ef4  
    1 <?php echo $html->docType('xhtml-strict'); ?> 
     1<?php echo $this->Html->docType('xhtml-strict'); ?> 
    22<html xmlns="http://www.w3.org/1999/xhtml"> 
    33 
     
    55<title><?php echo $title_for_layout?></title> 
    66<?php  
    7   echo $html->charset('UTF-8')."\n"; 
    8   echo $html->meta('icon')."\n"; 
    9   echo $html->css('backend')."\n"; 
    10   echo $html->script('phtagr'); 
     7  echo $this->Html->charset('UTF-8')."\n"; 
     8  echo $this->Html->meta('icon')."\n"; 
     9  echo $this->Html->css('backend')."\n"; 
     10  echo $this->Html->script('phtagr'); 
    1111  echo $scripts_for_layout;  
    1212?> 
     
    1818 
    1919<div id="header"><div class="sub"> 
    20 <?php echo $html->link(__('Gallery', true), '/'); ?> 
     20<?php echo $this->Html->link(__('Gallery', true), '/'); ?> 
    2121</div></div> 
    2222 
     
    2626<div class="box"> 
    2727<h1>Menu</h1> 
    28 <?php echo $menu->menu('main'); ?> 
     28<?php echo $this->Menu->menu('main'); ?> 
    2929</div> 
    3030</div> 
     
    3535 
    3636<div id="footer"><div class="sub"> 
    37 <p>&copy; 2006-2011 by <?php echo $html->link("Gallery phTagr", 'http://www.phtagr.org'); ?></p> 
     37<p>&copy; 2006-2011 by <?php echo $this->Html->link("Gallery phTagr", 'http://www.phtagr.org'); ?></p> 
    3838</div></div> 
    3939</body> 
  • View/Layouts/default.ctp

    re449ecc0 r3605ef4  
    1 <?php echo $html->docType('xhtml-strict'); ?> 
     1<?php echo $this->Html->docType('xhtml-strict'); ?> 
    22<html xmlns="http://www.w3.org/1999/xhtml"> 
    33 
     
    55<title><?php echo $title_for_layout?></title> 
    66<?php  
    7   echo $html->charset('UTF-8')."\n"; 
    8   echo $html->meta('icon')."\n"; 
    9   echo $html->css('default')."\n"; 
    10   echo $html->script('jquery-1.5.1.min'); 
     7  echo $this->Html->charset('UTF-8')."\n"; 
     8  echo $this->Html->meta('icon')."\n"; 
     9  echo $this->Html->css('default')."\n"; 
     10  echo $this->Html->script('jquery-1.5.1.min'); 
    1111  // jquery ui 
    12   echo $html->css('custom-phtagr/jquery-ui-1.8.14.custom'); 
    13   echo $html->script('jquery-ui-1.8.14.custom.min'); 
     12  echo $this->Html->css('custom-phtagr/jquery-ui-1.8.14.custom'); 
     13  echo $this->Html->script('jquery-ui-1.8.14.custom.min'); 
    1414 
    15   echo $html->script('jquery-phtagr'); 
     15  echo $this->Html->script('jquery-phtagr'); 
    1616  echo $scripts_for_layout;  
    1717  echo $feeds_for_layout; 
     
    2222 
    2323<div id="header"><div class="sub"> 
    24 <h1><?php echo $option->get('general.title', 'phTagr.'); ?></h1> 
    25 <span class="subtitle"><?php echo $option->get('general.subtitle', 'Tag Your Photos Once And Find Them Forever'); ?></span> 
    26 <?php echo $menu->menu('top-menu'); ?> 
     24<h1><?php echo $this->Option->get('general.title', 'phTagr.'); ?></h1> 
     25<span class="subtitle"><?php echo $this->Option->get('general.subtitle', 'Tag Your Photos Once And Find Them Forever'); ?></span> 
     26<?php echo $this->Menu->menu('top-menu'); ?> 
    2727</div></div><!-- #header/sub --> 
    2828 
    2929<div id="main-menu"><div class="sub"> 
    30 <?php echo $menu->menu('main-menu'); ?> 
     30<?php echo $this->Menu->menu('main-menu'); ?> 
    3131</div></div><!-- #main-menu/sub --> 
    3232 
     
    4040 
    4141<div id="footer"><div class="sub"> 
    42 <p>&copy; 2006-2011 by <?php echo $html->link("Open Source Web Gallery phTagr", 'http://www.phtagr.org'); ?></p> 
     42<p>&copy; 2006-2011 by <?php echo $this->Html->link("Open Source Web Gallery phTagr", 'http://www.phtagr.org'); ?></p> 
    4343</div></div><!-- #footer/sub --> 
    4444 
  • View/Setup/admin_upgrade.ctp

    re449ecc0 r3605ef4  
    11<h1><?php __("Database upgrade"); ?></h1> 
    22 
    3 <?php echo $session->flash(); ?> 
     3<?php echo $this->Session->flash(); ?> 
    44 
    55<div class="info"> 
     
    77</div> 
    88 
    9 <?php echo $html->link(__("Upgrade", true), '/admin/setup/upgrade/run'); ?> or  
    10 <?php echo $html->link(__("Cancel", true), '/'); ?> 
     9<?php echo $this->Html->link(__("Upgrade", true), '/admin/setup/upgrade/run'); ?> or  
     10<?php echo $this->Html->link(__("Cancel", true), '/'); ?> 
    1111 
  • View/Users/login.ctp

    re449ecc0 r3605ef4  
    1 <?php echo $session->flash(); ?> 
     1<?php echo $this->Session->flash(); ?> 
    22 
    3 <?php echo $form->create('User', array('action' => 'login', 'class' => 'login')); ?> 
     3<?php echo $this->Form->create('User', array('action' => 'login', 'class' => 'login')); ?> 
    44<fieldset> 
    55<legend><?php __('Login'); ?></legend> 
    66<?php 
    7   echo $form->input('User.username', array('label' => __('Username', true))); 
    8   echo $form->input('User.password', array('label' => __('Password', true))); 
     7  echo $this->Form->input('User.username', array('label' => __('Username', true))); 
     8  echo $this->Form->input('User.password', array('label' => __('Password', true))); 
    99?> 
    1010</fieldset> 
     
    1313  $signup = ''; 
    1414   
    15   echo $form->submit(__('Login', true), array('div' => false)); 
     15  echo $this->Form->submit(__('Login', true), array('div' => false)); 
    1616  if ($register) { 
    17     echo " ".$html->link(__('Sign Up', true), 'register', array('class' => 'button'))." "; 
     17    echo " ".$this->Html->link(__('Sign Up', true), 'register', array('class' => 'button'))." "; 
    1818  } 
    19   echo "<br/>".$html->link(__('Forgot your password', true), 'password'); 
     19  echo "<br/>".$this->Html->link(__('Forgot your password', true), 'password'); 
    2020?> 
    2121</div> 
    2222<?php  
    23   echo $form->end(); 
     23  echo $this->Form->end(); 
    2424  $script = <<<'JS' 
    2525(function($) { 
  • View/home/index.ctp

    re449ecc0 r3605ef4  
    11<div id="random-media"> 
    2 <h3><?php __("Random Media"); ?></h3> 
     2<h3><?php echo __("Random Media"); ?></h3> 
    33<?php  
    44  if (count($randomMedia)) { 
    55    $media = $randomMedia[0]; 
    6     $params = '/'.$search->serialize(array('sort' => 'random')); 
     6    $params = '/'.$this->Search->serialize(array('sort' => 'random')); 
    77 
    8     $cite = "<cite>" . sprintf(__("%s by %s", true), h($media['Media']['name']), $html->link($media['User']['username'], '/explorer/user/' . $media['User']['username'])) . "</cite>"; 
     8    $cite = "<cite>" . __("%s by %s", h($media['Media']['name']), $this->Html->link($media['User']['username'], '/explorer/user/' . $media['User']['username'])) . "</cite>"; 
    99 
    10     echo $html->tag('div',  
    11       $imageData->mediaLink($media, array('type' => 'preview', 'params' => $params, 'width' => 470)).$cite, 
     10    echo $this->Html->tag('div',  
     11      $this->ImageData->mediaLink($media, array('type' => 'preview', 'params' => $params, 'width' => 470)).$cite, 
    1212      array('class' => 'clip', 'escape' => false)); 
    1313 
    14     $link = $search->getUri(array('sort' => 'random')); 
    15     echo "<p>" . sprintf(__("See more %s", true), $html->link(__('random media...', true), $link))."</p>"; 
     14    $link = $this->Search->getUri(array('sort' => 'random')); 
     15    echo "<p>" . __("See more %s", $this->Html->link(__('random media...', true), $link))."</p>"; 
    1616  }  
    1717?> 
     
    1919 
    2020<div id="newest-media"> 
    21 <h3><?php __("Newest Media"); ?></h3> 
     21<h3><?php echo __("Newest Media"); ?></h3> 
    2222<?php 
    2323  $links = array(); 
     
    2929    } 
    3030    $pos = $i + 1; 
    31     $page = ceil($pos / $search->getShow(12)); 
    32     $params = '/'.$search->serialize(array('sort' => 'newest', 'page' => $page, 'pos' => $pos), false, false, array('defaults' => array('pos' => 1))); 
    33     $links[] = $imageData->mediaLink($newMedia[$i], array('type' => 'mini', 'params' => $params)); 
     31    $page = ceil($pos / $this->Search->getShow(12)); 
     32    $params = '/'.$this->Search->serialize(array('sort' => 'newest', 'page' => $page, 'pos' => $pos), false, false, array('defaults' => array('pos' => 1))); 
     33    $links[] = $this->ImageData->mediaLink($newMedia[$i], array('type' => 'mini', 'params' => $params)); 
    3434  } 
    35   echo $html->tag('div', implode("\n", $links), array('class' => 'images', 'escape' => false)); 
    36   $link = $search->getUri(array('sort' => 'newest')); 
    37   echo "<p>" . sprintf(__("See %s", true), $html->link(__('all new media...', true), $link))."</p>"; 
     35  echo $this->Html->tag('div', implode("\n", $links), array('class' => 'images', 'escape' => false)); 
     36  $link = $this->Search->getUri(array('sort' => 'newest')); 
     37  echo "<p>" . __("See %s", $this->Html->link(__('all new media...', true), $link))."</p>"; 
    3838?> 
    3939</div> 
    4040 
    4141<div id="recent-comments"> 
    42 <h3><?php __("Recent Comments"); ?></h3> 
     42<h3><?php echo __("Recent Comments"); ?></h3> 
    4343<?php if ($comments): ?> 
    4444<div class="comments"> 
     
    4646<?php foreach ($comments as $comment): ?> 
    4747<div class="comment <?php echo ($count++ % 2) ? 'even' : 'odd'; ?>"> 
    48 <?php echo $imageData->mediaLink($comment, array('type' => 'mini', 'div' => 'image')); ?> 
     48<?php echo $this->ImageData->mediaLink($comment, array('type' => 'mini', 'div' => 'image')); ?> 
    4949<div class="meta"> 
    5050<span class="from"><?php echo $comment['Comment']['name'] ?></span> said  
     
    5858<?php endforeach; /* comments */ ?> 
    5959</div><!-- comments --> 
    60 <p><?php echo $html->link(__("Older comments...", true), "/comments", array('escape' => false));?></p> 
     60<p><?php echo $this->Html->link(__("Older comments..."), "/comments", array('escape' => false));?></p> 
    6161<?php endif; ?>     
    6262</div> 
    6363 
    6464<div id="tag-cloud"> 
    65 <h3><?php __("Popular Tags"); ?></h3> 
     65<h3><?php echo __("Popular Tags"); ?></h3> 
    6666<div class="cloud"> 
    6767<?php 
    6868if (isset($cloudTags) && count($cloudTags)) { 
    69   echo $cloud->cloud($cloudTags, '/explorer/tag/'); 
     69  echo $this->Cloud->cloud($cloudTags, '/explorer/tag/'); 
    7070} else { 
    7171  echo '<p>' . __("No tags assigned") . '</p>'; 
     
    7575 
    7676<div id="category-cloud"> 
    77 <h3><?php __("Popular Categories"); ?></h3> 
     77<h3><?php echo __("Popular Categories"); ?></h3> 
    7878<div class="cloud"> 
    7979<?php 
    8080if (isset($cloudCategories) && count($cloudCategories)) { 
    81   echo $cloud->cloud($cloudCategories, '/explorer/category/'); 
     81  echo $this->Cloud->cloud($cloudCategories, '/explorer/category/'); 
    8282} else { 
    8383  echo '<p>' . __("No categories assigned") . '</p>';