Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Fixing to work with K3

  • Loading branch information...
commit 219d2286dfa483c5982207ef454d3ef00b64a497 1 parent 1c0206a
@deepwinter deepwinter authored
Showing with 15 additions and 1,475 deletions.
  1. +4 −0 application/bootstrap.php
  2. +0 −18 modules/mop_auth/controllers/mop_auth.php
  3. +0 −7 modules/mop_auth/views/logged_in_as.php
  4. +2 −1  modules/mopcms/classes/model/content.php
  5. +5 −5 modules/mopcms/classes/mop/cmsinterface.php
  6. BIN  modules/mopcms/views/images/admin/bg_row.gif
  7. BIN  modules/mopcms/views/images/admin/bg_row_alt.gif
  8. BIN  modules/mopcms/views/images/admin/bg_white60.png
  9. BIN  modules/mopcms/views/images/admin/bg_white80.png
  10. BIN  modules/mopcms/views/images/admin/bgk80.png
  11. BIN  modules/mopcms/views/images/admin/bgk88.png
  12. BIN  modules/mopcms/views/images/admin/bgk90.png
  13. BIN  modules/mopcms/views/images/admin/bgk94.png
  14. BIN  modules/mopcms/views/images/admin/icon_add_category.gif
  15. BIN  modules/mopcms/views/images/admin/icon_addpage.gif
  16. BIN  modules/mopcms/views/images/admin/icon_addpage.jpg
  17. BIN  modules/mopcms/views/images/admin/icon_cancel.gif
  18. BIN  modules/mopcms/views/images/admin/icon_cancel.png
  19. BIN  modules/mopcms/views/images/admin/icon_cancel_hover.png
  20. BIN  modules/mopcms/views/images/admin/icon_confirm.gif
  21. BIN  modules/mopcms/views/images/admin/icon_confirm.png
  22. BIN  modules/mopcms/views/images/admin/icon_confirm_hover.png
  23. BIN  modules/mopcms/views/images/admin/icon_delete.gif
  24. BIN  modules/mopcms/views/images/admin/icon_delete.png
  25. BIN  modules/mopcms/views/images/admin/icon_delete_hover.png
  26. BIN  modules/mopcms/views/images/admin/icon_download.png
  27. BIN  modules/mopcms/views/images/admin/icon_folder.gif
  28. BIN  modules/mopcms/views/images/admin/icon_folder_hover.gif
  29. BIN  modules/mopcms/views/images/admin/icon_folderadd.gif
  30. BIN  modules/mopcms/views/images/admin/icon_folderadd_hover.gif
  31. BIN  modules/mopcms/views/images/admin/icon_folderopen.gif
  32. BIN  modules/mopcms/views/images/admin/icon_folderopen_hover.gif
  33. BIN  modules/mopcms/views/images/admin/icon_gif.gif
  34. BIN  modules/mopcms/views/images/admin/icon_jpg.gif
  35. BIN  modules/mopcms/views/images/admin/icon_none.gif
  36. BIN  modules/mopcms/views/images/admin/icon_pdf.gif
  37. BIN  modules/mopcms/views/images/admin/icon_png.gif
  38. BIN  modules/mopcms/views/images/admin/icon_published.gif
  39. BIN  modules/mopcms/views/images/admin/icon_published_hover.gif
  40. BIN  modules/mopcms/views/images/admin/icon_sort.png
  41. BIN  modules/mopcms/views/images/admin/icon_sort_hover.png
  42. BIN  modules/mopcms/views/images/admin/icon_trash.gif
  43. BIN  modules/mopcms/views/images/admin/icon_unpublished.gif
  44. BIN  modules/mopcms/views/images/admin/icon_unpublished_hover.gif
  45. BIN  modules/mopcms/views/images/admin/icon_upload.png
  46. BIN  modules/mopcms/views/images/admin/icon_view.png
  47. BIN  modules/mopcms/views/images/admin/navbg.gif
  48. BIN  modules/mopcms/views/images/admin/spinner.gif
  49. BIN  modules/mopcms/views/images/admin/switch_handle.png
  50. BIN  modules/mopcms/views/images/admin/switch_track.png
  51. BIN  modules/mopcms/views/images/bar.gif
  52. BIN  modules/mopcms/views/images/bg_row.gif
  53. BIN  modules/mopcms/views/images/bg_row_alt.gif
  54. BIN  modules/mopcms/views/images/bg_white60.png
  55. BIN  modules/mopcms/views/images/bg_white80.png
  56. BIN  modules/mopcms/views/images/bgk80.png
  57. BIN  modules/mopcms/views/images/bgk88.png
  58. BIN  modules/mopcms/views/images/bgk90.png
  59. BIN  modules/mopcms/views/images/bgk94.png
  60. BIN  modules/mopcms/views/images/failed.png
  61. BIN  modules/mopcms/views/images/file.png
  62. BIN  modules/mopcms/views/images/guideBg.gif
  63. BIN  modules/mopcms/views/images/icon_add_category.gif
  64. BIN  modules/mopcms/views/images/icon_addpage.gif
  65. BIN  modules/mopcms/views/images/icon_addpage.jpg
  66. BIN  modules/mopcms/views/images/icon_cancel.gif
  67. BIN  modules/mopcms/views/images/icon_cancel.png
  68. BIN  modules/mopcms/views/images/icon_cancel_hover.png
  69. BIN  modules/mopcms/views/images/icon_confirm.gif
  70. BIN  modules/mopcms/views/images/icon_confirm.png
  71. BIN  modules/mopcms/views/images/icon_confirm_hover.png
  72. BIN  modules/mopcms/views/images/icon_delete.gif
  73. BIN  modules/mopcms/views/images/icon_delete.png
  74. BIN  modules/mopcms/views/images/icon_delete_hover.png
  75. BIN  modules/mopcms/views/images/icon_doc.gif
  76. BIN  modules/mopcms/views/images/icon_download.png
  77. BIN  modules/mopcms/views/images/icon_folder.gif
  78. BIN  modules/mopcms/views/images/icon_folder_hover.gif
  79. BIN  modules/mopcms/views/images/icon_folderadd.gif
  80. BIN  modules/mopcms/views/images/icon_folderadd_hover.gif
  81. BIN  modules/mopcms/views/images/icon_folderopen.gif
  82. BIN  modules/mopcms/views/images/icon_folderopen_hover.gif
  83. BIN  modules/mopcms/views/images/icon_gif.gif
  84. BIN  modules/mopcms/views/images/icon_jpg.gif
  85. BIN  modules/mopcms/views/images/icon_none.gif
  86. BIN  modules/mopcms/views/images/icon_pdf.gif
  87. BIN  modules/mopcms/views/images/icon_png.gif
  88. BIN  modules/mopcms/views/images/icon_published.gif
  89. BIN  modules/mopcms/views/images/icon_published_hover.gif
  90. BIN  modules/mopcms/views/images/icon_sort.png
  91. BIN  modules/mopcms/views/images/icon_sort_hover.png
  92. BIN  modules/mopcms/views/images/icon_trash.gif
  93. BIN  modules/mopcms/views/images/icon_unpublished.gif
  94. BIN  modules/mopcms/views/images/icon_unpublished_hover.gif
  95. BIN  modules/mopcms/views/images/icon_upload.png
  96. BIN  modules/mopcms/views/images/icon_view.png
  97. BIN  modules/mopcms/views/images/navbg.gif
  98. BIN  modules/mopcms/views/images/progress.gif
  99. BIN  modules/mopcms/views/images/spinner.gif
  100. BIN  modules/mopcms/views/images/success.png
  101. BIN  modules/mopcms/views/images/switch_handle.png
  102. BIN  modules/mopcms/views/images/switch_track.png
  103. BIN  modules/mopcms/views/images/uploading.png
  104. +3 −1 modules/mopcore/classes/controller/ajax.php
  105. +1 −1  modules/mopcore/classes/mop.php
  106. +0 −103 modules/mopmvc/helpers/moputil.php
  107. BIN  modules/tools/controllers/.dumper.php.swp
  108. +0 −193 modules/tools/controllers/builder.php
  109. +0 −187 modules/tools/controllers/builder.php.generatecms
  110. +0 −151 modules/tools/controllers/configsite.php
  111. +0 −293 modules/tools/controllers/dumper.php
  112. +0 −172 modules/tools/controllers/frontend.php
  113. +0 −42 modules/tools/controllers/mopsetup.php
  114. +0 −47 modules/tools/controllers/testbed.php
  115. +0 −22 modules/tools/controllers/tests.php
  116. +0 −7 modules/usermanagement/config/cms.php
  117. +0 −225 modules/usermanagement/controllers/usermanagement.php
  118. 0  staging/application/media/.gitignore
View
4 application/bootstrap.php
@@ -113,7 +113,11 @@
'mopcore' => MODPATH.'mopcore',
'mopcms' => MODPATH.'mopcms',
'mopui' => MODPATH.'mopui',
+ 'mopextras' => MODPATH.'mopextras',
'navigation' => MODPATH.'navigation',
+ 'tools' => MODPATH.'tools',
+ 'usermanagement' => MODPATH.'usermanagement',
+
));
View
18 modules/mop_auth/controllers/mop_auth.php
@@ -1,18 +0,0 @@
-<?
-/*
- * Class: MOP_Auth_Controller
- * Reponsible for the 'logged in as' object on the MOP backend pages
- */
-class MOP_Auth_Controller extends Controller {
-
- /*
- * Function: createIndexView()
- * Implements abstract function in base assigning the main view
- */
- public function createIndexView(){
- $this->view = new View('logged_in_as');
- if(Session::instance()->get('auth_user')){
- $this->view->username = $_SESSION['auth_user']->username;
- }
- }
-}
View
7 modules/mop_auth/views/logged_in_as.php
@@ -1,7 +0,0 @@
-<div class="loginstatus">
- <div class="controls">
- <?if(isset($username)):?>
- You are logged in as: <?=$username;?> <a class="button" href="<?=Kohana::config('config.site_path');?>auth/logout/">logout</a>
- <?endif;?>
- </div>
-</div>
View
3  modules/mopcms/classes/model/content.php
@@ -45,8 +45,8 @@ public function __get($column){
//check for dbmap
$object = ORM::Factory('page', parent::__get('page_id'));
//echo 'FROM '.$object->id.'<br>';
+
$column = mop::dbmap( $object->template_id, $column);
- //echo 'which maps to'.$column;
if(!$column){
throw new Kohana_Exception('Column :column not found in content model', array(':column', $column));
}
@@ -71,6 +71,7 @@ public function __get($column){
return $returnval;
}
+
/*
Function: __set
View
10 modules/mopcms/classes/mop/cmsinterface.php
@@ -90,7 +90,7 @@ public function action_savefield($id){
$page->save();
$page->contenttable->$_POST['field'] = mopcms::convertNewlines($_POST['value']);
$page->contenttable->save();
- $page = ORM::Factory('page')->find($id);
+ $page = ORM::Factory('page')->where('id', '=', $id)->find();
return array('value'=>$page->contenttable->$_POST['field'], 'slug'=>$page->slug);
}
else if(in_array($_POST['field'], array('dateadded'))){
@@ -139,7 +139,7 @@ public function action_savefield($id){
throw new Kohana_User_Exception('Invalid POST', 'Invalid POST Arguments');
}
- $page = ORM::Factory('page')->find($id);
+ $page = ORM::Factory('page')->where('id', '=', $id)->find();
//echo $_POST['field'];
$value = $page->contenttable->$_POST['field'];
$this->response->data(array('value'=>$value));
@@ -153,7 +153,7 @@ public function action_savefield($id){
Returns: Published status (0 or 1)
*/
public function action_togglePublish($id){
- $page = ORM::Factory('page')->find($id);
+ $page = ORM::Factory('page')->where('id', '=', $id)->find();
if($page->published==0){
$page->published = 1;
} else {
@@ -220,7 +220,7 @@ public function action_undelete($id) {
* Returns: nothing
*/
private function cascade_delete($id){
- $page = ORM::Factory('page')->find($id);
+ $page = ORM::Factory('page')->where('id', '=', $id)->find();
$page->activity = 'D';
$page->sortorder = 0;
$page->slug = new Database_Expr('NULL');
@@ -244,7 +244,7 @@ private function cascade_delete($id){
* Returns: Nothing
*/
private function cascade_undelete($page_id){
- $page = ORM::Factory('page')->find($id);
+ $page = ORM::Factory('page')->where('id', '=', $id)->find();
$page->activity = new Database_Expr('NULL');
$page->slug = mopcms::createSlug($page->contenttable->title, $page->id);
$page->save();
View
BIN  modules/mopcms/views/images/admin/bg_row.gif
Deleted file not rendered
View
BIN  modules/mopcms/views/images/admin/bg_row_alt.gif
Deleted file not rendered
View
BIN  modules/mopcms/views/images/admin/bg_white60.png
Deleted file not rendered
View
BIN  modules/mopcms/views/images/admin/bg_white80.png
Deleted file not rendered
View
BIN  modules/mopcms/views/images/admin/bgk80.png
Deleted file not rendered
View
BIN  modules/mopcms/views/images/admin/bgk88.png
Deleted file not rendered
View
BIN  modules/mopcms/views/images/admin/bgk90.png
Deleted file not rendered
View
BIN  modules/mopcms/views/images/admin/bgk94.png
Deleted file not rendered
View
BIN  modules/mopcms/views/images/admin/icon_add_category.gif
Deleted file not rendered
View
BIN  modules/mopcms/views/images/admin/icon_addpage.gif
Deleted file not rendered
View
BIN  modules/mopcms/views/images/admin/icon_addpage.jpg
Deleted file not rendered
View
BIN  modules/mopcms/views/images/admin/icon_cancel.gif
Deleted file not rendered
View
BIN  modules/mopcms/views/images/admin/icon_cancel.png
Deleted file not rendered
View
BIN  modules/mopcms/views/images/admin/icon_cancel_hover.png
Deleted file not rendered
View
BIN  modules/mopcms/views/images/admin/icon_confirm.gif
Deleted file not rendered
View
BIN  modules/mopcms/views/images/admin/icon_confirm.png
Deleted file not rendered
View
BIN  modules/mopcms/views/images/admin/icon_confirm_hover.png
Deleted file not rendered
View
BIN  modules/mopcms/views/images/admin/icon_delete.gif
Deleted file not rendered
View
BIN  modules/mopcms/views/images/admin/icon_delete.png
Deleted file not rendered
View
BIN  modules/mopcms/views/images/admin/icon_delete_hover.png
Deleted file not rendered
View
BIN  modules/mopcms/views/images/admin/icon_download.png
Deleted file not rendered
View
BIN  modules/mopcms/views/images/admin/icon_folder.gif
Deleted file not rendered
View
BIN  modules/mopcms/views/images/admin/icon_folder_hover.gif
Deleted file not rendered
View
BIN  modules/mopcms/views/images/admin/icon_folderadd.gif
Deleted file not rendered
View
BIN  modules/mopcms/views/images/admin/icon_folderadd_hover.gif
Deleted file not rendered
View
BIN  modules/mopcms/views/images/admin/icon_folderopen.gif
Diff not rendered
View
BIN  modules/mopcms/views/images/admin/icon_folderopen_hover.gif
Diff not rendered
View
BIN  modules/mopcms/views/images/admin/icon_gif.gif
Diff not rendered
View
BIN  modules/mopcms/views/images/admin/icon_jpg.gif
Diff not rendered
View
BIN  modules/mopcms/views/images/admin/icon_none.gif
Diff not rendered
View
BIN  modules/mopcms/views/images/admin/icon_pdf.gif
Diff not rendered
View
BIN  modules/mopcms/views/images/admin/icon_png.gif
Diff not rendered
View
BIN  modules/mopcms/views/images/admin/icon_published.gif
Diff not rendered
View
BIN  modules/mopcms/views/images/admin/icon_published_hover.gif
Diff not rendered
View
BIN  modules/mopcms/views/images/admin/icon_sort.png
Diff not rendered
View
BIN  modules/mopcms/views/images/admin/icon_sort_hover.png
Diff not rendered
View
BIN  modules/mopcms/views/images/admin/icon_trash.gif
Diff not rendered
View
BIN  modules/mopcms/views/images/admin/icon_unpublished.gif
Diff not rendered
View
BIN  modules/mopcms/views/images/admin/icon_unpublished_hover.gif
Diff not rendered
View
BIN  modules/mopcms/views/images/admin/icon_upload.png
Diff not rendered
View
BIN  modules/mopcms/views/images/admin/icon_view.png
Diff not rendered
View
BIN  modules/mopcms/views/images/admin/navbg.gif
Diff not rendered
View
BIN  modules/mopcms/views/images/admin/spinner.gif
Diff not rendered
View
BIN  modules/mopcms/views/images/admin/switch_handle.png
Diff not rendered
View
BIN  modules/mopcms/views/images/admin/switch_track.png
Diff not rendered
View
BIN  modules/mopcms/views/images/bar.gif
Diff not rendered
View
BIN  modules/mopcms/views/images/bg_row.gif
Diff not rendered
View
BIN  modules/mopcms/views/images/bg_row_alt.gif
Diff not rendered
View
BIN  modules/mopcms/views/images/bg_white60.png
Diff not rendered
View
BIN  modules/mopcms/views/images/bg_white80.png
Diff not rendered
View
BIN  modules/mopcms/views/images/bgk80.png
Diff not rendered
View
BIN  modules/mopcms/views/images/bgk88.png
Diff not rendered
View
BIN  modules/mopcms/views/images/bgk90.png
Diff not rendered
View
BIN  modules/mopcms/views/images/bgk94.png
Diff not rendered
View
BIN  modules/mopcms/views/images/failed.png
Diff not rendered
View
BIN  modules/mopcms/views/images/file.png
Diff not rendered
View
BIN  modules/mopcms/views/images/guideBg.gif
Diff not rendered
View
BIN  modules/mopcms/views/images/icon_add_category.gif
Diff not rendered
View
BIN  modules/mopcms/views/images/icon_addpage.gif
Diff not rendered
View
BIN  modules/mopcms/views/images/icon_addpage.jpg
Diff not rendered
View
BIN  modules/mopcms/views/images/icon_cancel.gif
Diff not rendered
View
BIN  modules/mopcms/views/images/icon_cancel.png
Diff not rendered
View
BIN  modules/mopcms/views/images/icon_cancel_hover.png
Diff not rendered
View
BIN  modules/mopcms/views/images/icon_confirm.gif
Diff not rendered
View
BIN  modules/mopcms/views/images/icon_confirm.png
Diff not rendered
View
BIN  modules/mopcms/views/images/icon_confirm_hover.png
Diff not rendered
View
BIN  modules/mopcms/views/images/icon_delete.gif
Diff not rendered
View
BIN  modules/mopcms/views/images/icon_delete.png
Diff not rendered
View
BIN  modules/mopcms/views/images/icon_delete_hover.png
Diff not rendered
View
BIN  modules/mopcms/views/images/icon_doc.gif
Diff not rendered
View
BIN  modules/mopcms/views/images/icon_download.png
Diff not rendered
View
BIN  modules/mopcms/views/images/icon_folder.gif
Diff not rendered
View
BIN  modules/mopcms/views/images/icon_folder_hover.gif
Diff not rendered
View
BIN  modules/mopcms/views/images/icon_folderadd.gif
Diff not rendered
View
BIN  modules/mopcms/views/images/icon_folderadd_hover.gif
Diff not rendered
View
BIN  modules/mopcms/views/images/icon_folderopen.gif
Diff not rendered
View
BIN  modules/mopcms/views/images/icon_folderopen_hover.gif
Diff not rendered
View
BIN  modules/mopcms/views/images/icon_gif.gif
Diff not rendered
View
BIN  modules/mopcms/views/images/icon_jpg.gif
Diff not rendered
View
BIN  modules/mopcms/views/images/icon_none.gif
Diff not rendered
View
BIN  modules/mopcms/views/images/icon_pdf.gif
Diff not rendered
View
BIN  modules/mopcms/views/images/icon_png.gif
Diff not rendered
View
BIN  modules/mopcms/views/images/icon_published.gif
Diff not rendered
View
BIN  modules/mopcms/views/images/icon_published_hover.gif
Diff not rendered
View
BIN  modules/mopcms/views/images/icon_sort.png
Diff not rendered
View
BIN  modules/mopcms/views/images/icon_sort_hover.png
Diff not rendered
View
BIN  modules/mopcms/views/images/icon_trash.gif
Diff not rendered
View
BIN  modules/mopcms/views/images/icon_unpublished.gif
Diff not rendered
View
BIN  modules/mopcms/views/images/icon_unpublished_hover.gif
Diff not rendered
View
BIN  modules/mopcms/views/images/icon_upload.png
Diff not rendered
View
BIN  modules/mopcms/views/images/icon_view.png
Diff not rendered
View
BIN  modules/mopcms/views/images/navbg.gif
Diff not rendered
View
BIN  modules/mopcms/views/images/progress.gif
Diff not rendered
View
BIN  modules/mopcms/views/images/spinner.gif
Diff not rendered
View
BIN  modules/mopcms/views/images/success.png
Diff not rendered
View
BIN  modules/mopcms/views/images/switch_handle.png
Diff not rendered
View
BIN  modules/mopcms/views/images/switch_track.png
Diff not rendered
View
BIN  modules/mopcms/views/images/uploading.png
Diff not rendered
View
4 modules/mopcore/classes/controller/ajax.php
@@ -28,12 +28,14 @@ public function action_data($uri)
$data = $subRequest->execute()->data();
} catch (Exception $e) {
//return HTML from exception
- $message = $e->getString() . $e->getTrace();
+ $message = $e->getMessage() . $e->getTrace();
$ajaxResponse = array(
'returnValue' => TRUE,
'response' => $message
);
+ $this->responase->body(json_encode($data));
+ // throw $e;
return;
}
$ajaxResponse = array(
View
2  modules/mopcore/classes/mop.php
@@ -119,7 +119,7 @@ public static function config($arena, $xpath, $contextNode=null){
}
public static function dbmap($template_id, $column=null){
- if(!isset(self::$dbmaps[$template_id])){
+ if(!isset(self::$dbmaps[$template_id])){
$dbmaps = ORM::Factory('objectmap')->where('template_id', '=', $template_id)->find_all();
self::$dbmaps[$template_id] = array();
foreach($dbmaps as $map){
View
103 modules/mopmvc/helpers/moputil.php
@@ -1,103 +0,0 @@
-<?
-
-/*
- * Class: moputil
- * Utility helper class
- */
-Class moputil {
-
- /*
- * Function: getMicroSeconds()
- * Returns a microseconds of current time as a 3 place float
- * Returns: Microseconds
- */
- public static function getMicroSeconds(){
- list($usec, $sec) = explode(" ", microtime());
- return number_format((float)$usec, 3);
- }
-
- /*
- * Function getMicroTimestamp()
- * Creates a timestamp including microseconds
- * Returns: Microsecond timestamp
- */
- public static function getMicroTimestamp(){
- $timestamp = date('YmdHis') . substr(moputil::getMicroSeconds(), 1) ;
- Kohana::log('info', 'TIMESTAMP: '.$timestamp);
- return $timestamp;
- }
-
- /*
- * Function: img($file, $prefix, $alt, $extra = null){
- * Echos an image tag as built from a mop file object.
- * Parameters:
- * $file - mop file object
- * $prefix - the prefix to output
- * $alt - alt tag phrase
- * $extra - extra stuff to go inside the tag attributes area
- * Returns: if file exists, return the img src tag code, otherwise return null
- */
- public static function img($file, $prefix, $alt, $extra = null){
- if(!$file->$prefix->fullpath
- || !file_exists($file->$prefix->fullpath)){
- return null;
- }
- $img = sprintf('<img src="%s" width="%s" height="%s" alt="%s" %s>',
- $file->$prefix->fullpath,
- $file->$prefix->width,
- $file->$prefix->height,
- $alt,
- $extra);
- return $img;
- }
-
- /*
- * Function: checkRoleAccess($role)
- * Checks whether the currently logged in user has a certain role
- * Parameters:
- * $role - the role to check against
- * Returns: true or false
- */
- public static function checkRoleAccess($role){
-
- if($role && !Auth::instance()->logged_in($role)){
- return false;
- } else {
- return true;
- }
- }
-
- /*
- * Function: decode_recurse($value)
- */
- private static function decode_recurse($value){
- //handle object?
- if(!is_array($value)){
- return html_entity_decode($value);
- } else {
- for($i=0, $keys=array_keys($value), $count=count($value); $i<$count; $i++){
- $value[$keys[$i]] = moputil::decode_recurse($value[$keys[$i]]);
- }
- return $value;
- }
- }
-
- public static $modulos;
- public static $modulosOptionsCount;
- public static function modulo($identifier, $options){
- self::$modulosOptionsCount = count( $options );
- if(!is_array(self::$modulos)){
- self::$modulos = array();
- }
- if(!isset(self::$modulos[$identifier])){
- self::$modulos[$identifier] = 0;
- }
- $index = self::$modulos[$identifier];
- self::$modulos[$identifier]++;
- return $options[$index%self::$modulosOptionsCount];
-
- }
-
-
-
-}
View
BIN  modules/tools/controllers/.dumper.php.swp
Binary file not shown
View
193 modules/tools/controllers/builder.php
@@ -1,193 +0,0 @@
-<?
-
-class builder_Controller extends Controller {
-
- private $newObjectIds = array();
-
- public function __construct(){
- if(!is_writable('application/views/generated/')){
- die('application/views/generated/ must be writable');
- }
- }
-
- public function destroy($dir) {
- $mydir = opendir($dir);
- while(false !== ($file = readdir($mydir))) {
- if($file != "." && $file != "..") {
- // chmod($dir.$file, 0777);
- if(is_dir($dir.$file)) {
- chdir('.');
- destroy($dir.$file.'/');
- rmdir($dir.$file) or DIE("couldn't delete $dir$file<br />");
- }
- else
- unlink($dir.$file) or DIE("couldn't delete $dir$file<br />");
- }
- }
- closedir($mydir);
- }
-
- public function initializeSite($xmlFile='data'){
- //get directory listing of application/media
- //and unlink all files
-
- $db = Database::instance();
- $db->query('delete from pages');
- $db->query('alter table pages AUTO_INCREMENT = 1');
- $db->query('delete from contents');
- $db->query('alter table contents AUTO_INCREMENT = 1');
- $db->query('delete from templates');
- $db->query('alter table templates AUTO_INCREMENT = 1');
- flush();
- ob_flush();
-
- //clean out media dir
- $this->destroy('application/media/');
- $this->destroy('staging/application/media/');
-
-
- echo "\nInserting Data\n";
- $this->insertData($xmlFile);
-
- cms::regenerateImages();
-
- //and run frontend
- echo "\n Regenerating Fronted";
- $frontend = new Frontend_Controller();
- $frontend->index();
-
- }
-
- public function addData($xmlFile){
- $this->insertData($xmlFile);
-
- cms::generateNewImages($this->newObjectIds);
- }
-
-
-
- public function insertData($xmlFile, $parentId = 0, $context=null){
-
- foreach(mop::config($xmlFile, 'item', $context) as $item){
- $lists = array();
- if(!$item->getAttribute('templateName')){
- echo $item->tagName;
- die("No templatename specified for Item ".$item->tagName."\n\n");
- }
- //echo "\n found contentnod ".$item->getAttribute('templateName');
- flush();
- ob_flush();
- $object = ORM::Factory('page');
- $template = ORM::Factory('template', $item->getAttribute('templateName'));
- if($template->nodeType == 'container'){
- die("Can't add list family as template name in data.xml: {$template->templatename} \n");
- }
-
- //echo ')))'.$item->getAttribute('templateName');
- $data = array();
- foreach(mop::config($xmlFile, 'field', $item ) as $content){
- $field = $content->getAttribute('name');
- //echo 'This Fielad '.$field."\n\n";
- switch($field){
- case 'title':
- $data[$field] = $content->nodeValue;
- continue(2);
- case 'slug':
- $data[$field] = $content->nodeValue;
- $data['decoupleSlugTitle'] = 1;
- continue(2);
- default:
- $data[$field] = $content->nodeValue;
- break;
- }
-
-
- //need to look up field and switch on field type
- $fieldInfo = mop::config('objects', sprintf('//template[@name="%s"]/elements/*[@field="%s"]', $item->getAttribute('templateName'), $content->getAttribute('name')))->item(0);
- if(!$fieldInfo){
- die("Bad field in data/objects!\n". sprintf('//template[@name="%s"]/elements/*[@field="%s"]', $item->getAttribute('templateName'), $content->getAttribute('name')));
- }
- //echo "\ntagname\t".$fieldInfo->tagName."\n";
-
- //special setup based on field type
- switch($fieldInfo->tagName){
- case 'file':
- case 'image':
- $path_parts = pathinfo($content->nodeValue);
- $savename = cms::makeFileSaveName($path_parts['basename']);
- if(file_exists($content->nodeValue)){
- copy(str_replace('index.php', '', $_SERVER['SCRIPT_FILENAME']).$content->nodeValue, cms::mediapath($savename).$savename);
- } else {
- echo "File does not exist {$content->nodeValue} \n";
- die();
- }
- $data[$field] = $savename;
- break;
- default:
- $data[$field] = $content->nodeValue;
- break;
- }
-
- }
- $data['published'] = true;
- //echo 'parent'.$parentId;
- //print_r($data);
-
-
- foreach(mop::config($xmlFile, 'object', $item) as $object){
- $clusterData = array();
- foreach(mop::config($xmlFile, 'field', $object) as $clusterField){
- $clusterData[$clusterField->getAttribute('name')] = $clusterField->nodeValue;
- }
- $data[$object->getAttribute('name')] = $clusterData;
- }
-
-
- //now we check for a title collision
- //if there is a title collision, we assume that this is a component
- //already added at the next level up, in this case we just
- //update the objects data
- $existing = ORM::Factory('page')
- ->where('parentid', $parentId)
- ->find_all();
- $component = null;
- foreach($existing as $aComponent){
- //echo "\n\n".$aComponent->contenttable->title;
- if(isset($data['title'])){
- if($aComponent->contenttable->title == $data['title']){
- $component = $aComponent;
- break;
- }
- }
- }
- if($component){
- $component->updateWithArray($data);
- $objectId = $component->id;
- } else {
- $objectId = cms::addObject($parentId, $item->getAttribute('templateName'), $data);
- $this->newObjectIds[] = $objectId;
- }
-
- //do recursive if it has children
- if(mop::config($xmlFile, 'item', $item)->length ){
- $this->insertData($xmlFile, $objectId, $item);
- }
-
- foreach(mop::config($xmlFile, 'list', $item) as $list){
- //echo "FOUND A LIST\n\n";
- //find the container
- $listT = ORM::Factory('template', $list->getAttribute('family'));
- $container = ORM::Factory('page')
- ->where('parentid', $objectId)
- ->where('template_id', $listT->id)
- ->find();
- //jump down a level to add object
- $this->insertData($xmlFile, $container->id, $list);
- }
-
- }
-
- //and regenerate all files
- }
-
-}
View
187 modules/tools/controllers/builder.php.generatecms
@@ -1,187 +0,0 @@
-<?
-
-class builder_Controller extends Controller {
-
- private $newObjectIds = array();
-
- public function __construct(){
- if(!is_writable('application/views/generated/')){
- die('application/views/generated/ must be writable');
- }
- }
-
- public function initializeSite($xmlFile='data'){
- //get directory listing of application/media
- //and unlink all files
-
- $db = Database::instance();
- $db->query('delete from pages');
- $db->query('alter table pages AUTO_INCREMENT = 1');
- $db->query('delete from contents');
- $db->query('alter table contents AUTO_INCREMENT = 1');
- $db->query('delete from templates');
- $db->query('alter table templates AUTO_INCREMENT = 1');
- flush();
- ob_flush();
-
- echo "\nInserting Data\n";
- $this->insertData($xmlFile);
-
- cms::regenerateImages();
-
- //and run frontend
- echo "\n Regenerating Fronted";
- $frontend = new Frontend_Controller();
- $frontend->index();
-
- $this->generateCMSCustomViews();
-
- }
-
- public function addData($xmlFile){
- $this->insertData($xmlFile);
-
- cms::generateNewImages($this->newObjectIds);
- }
-
-
-
- public function insertData($xmlFile, $parentId = 0, $context=null){
-
- foreach(mop::config($xmlFile, 'item', $context) as $item){
- $lists = array();
- if(!$item->getAttribute('templateName')){
- echo $item->tagName;
- die("No templatename specified for Item ".$item->tagName."\n\n");
- }
- //echo "\n found contentnod ".$item->getAttribute('templateName');
- flush();
- ob_flush();
- $object = ORM::Factory('page');
- $template = ORM::Factory('template', $item->getAttribute('templateName'));
- if($template->nodeType == 'container'){
- die("Can't add list family as template name in data.xml: {$template->templatename} \n");
- }
-
- //echo ')))'.$item->getAttribute('templateName');
- $data = array();
- foreach(mop::config($xmlFile, 'field', $item ) as $content){
- $field = $content->getAttribute('name');
- //echo 'This Fielad '.$field."\n\n";
- switch($field){
- case 'title':
- $data[$field] = $content->nodeValue;
- continue(2);
- case 'slug':
- $data[$field] = $content->nodeValue;
- $data['decoupleSlugTitle'] = 1;
- continue(2);
- default:
- $data[$field] = $content->nodeValue;
- break;
- }
-
-
- //need to look up field and switch on field type
- $fieldInfo = mop::config('objects', sprintf('//template[@name="%s"]/elements/*[@field="%s"]', $item->getAttribute('templateName'), $content->getAttribute('name')))->item(0);
- if(!$fieldInfo){
- die("Bad field in builder!\n". sprintf('//template[@name="%s"]/elements/*[@field="%s"]', $item->getAttribute('templateName'), $content->tagName));
- }
- //echo "\ntagname\t".$fieldInfo->tagName."\n";
-
- //special setup based on field type
- switch($fieldInfo->tagName){
- case 'file':
- case 'image':
- $path_parts = pathinfo($content->nodeValue);
- $savename = cms::makeFileSaveName($path_parts['basename']);
- if(file_exists($content->nodeValue)){
- copy(str_replace('index.php', '', $_SERVER['SCRIPT_FILENAME']).$content->nodeValue, cms::mediapath($savename).$savename);
- } else {
- echo "File does not exist {$content->nodeValue} \n";
- die();
- }
- $data[$field] = $savename;
- break;
- default:
- $data[$field] = $content->nodeValue;
- break;
- }
-
- }
- $data['published'] = true;
- //echo 'parent'.$parentId;
- //print_r($data);
-
-
- foreach(mop::config($xmlFile, 'object', $item) as $object){
- $clusterData = array();
- foreach(mop::config($xmlFile, 'field', $object) as $clusterField){
- $clusterData[$clusterField->getAttribute('name')] = $clusterField->nodeValue;
- }
- $data[$object->getAttribute('name')] = $clusterData;
- }
-
-
- //now we check for a title collision
- //if there is a title collision, we assume that this is a component
- //already added at the next level up, in this case we just
- //update the objects data
- $existing = ORM::Factory('page')
- ->where('parentid', $parentId)
- ->find_all();
- $component = null;
- foreach($existing as $aComponent){
- //echo "\n\n".$aComponent->contenttable->title;
- if(isset($data['title'])){
- if($aComponent->contenttable->title == $data['title']){
- $component = $aComponent;
- break;
- }
- }
- }
- if($component){
- $component->updateWithArray($data);
- $objectId = $component->id;
- } else {
- $objectId = cms::addObject($parentId, $item->getAttribute('templateName'), $data);
- $this->newObjectIds[] = $objectId;
- }
-
- //do recursive if it has children
- if(mop::config($xmlFile, 'item', $item)->length ){
- $this->insertData($xmlFile, $objectId, $item);
- }
-
- foreach(mop::config($xmlFile, 'list', $item) as $list){
- //echo "FOUND A LIST\n\n";
- //find the container
- $listT = ORM::Factory('template', $list->getAttribute('family'));
- $container = ORM::Factory('page')
- ->where('parentid', $objectId)
- ->where('template_id', $listT->id)
- ->find();
- //jump down a level to add object
- $this->insertData($xmlFile, $container->id, $list);
- }
-
- }
-
- //and regenerate all files
- }
-
-
- public function generateCMSCustomViews() {
- foreach(mop::config('objects', '//template') as $template){
- $filename = 'application/views/generated/cms/cms_'.$template->getAttribute('name').'.php';
- touch($filename);
- $html = '';
- foreach(mop::config('objects', 'elements/*', $template) as $field){
- $html .="<?=$".$field->tagName.'_'.$field->getAttribute('field').";?>\n\n";
- }
- $file = fopen($filename, 'w');
- fwrite($file, $html);
- fclose($file);
- }
- }
-}
View
151 modules/tools/controllers/configsite.php
@@ -1,151 +0,0 @@
-<?
-set_error_handler(array('Cli', 'error_handler'), E_ALL);
-//set_exception_handler(('Cli::exception_handler'));
-require('modules/yaml/lib/sfYaml.php');
-require('modules/yaml/lib/sfYamlParser.php');
-
-Class ConfigSite_Controller extends Controller {
-
-
- //the final config outputs
- public function __construct(){
- parent::__construct();
- }
-
- public function index(){
- echo "Configuring Site\n";
-
- //load value from config to force validation
- mop::config('objects', '//configuration');
-
- $db = Database::instance();
- //validate objects.xml data
- $errors = array();
- $templates = array();
- foreach(mop::config('objects', '//template') as $template){
- $templates[] = $template->getAttribute('name');
- foreach(mop::config('objects', '//template[@name="'.$template->getAttribute('name').'"]/elements/*') as $item ){
- $field = $item->getAttribute('field');
- if(!preg_match('/^[A-z0-9]*$/', $field)){
- $errors[] = "Element field names must be alphanumeric. field=\"$field\" found in template ".$template->getAttribute('name');
- }
- }
- }
-
- foreach(mop::config('objects', '//addableObject') as $addable){
- $at = $addable->getAttribute('templateName');
- echo $at;
- if(!in_array($at, $templates)){
- $errors[] = "Addable object $at not defined as template in objects.xml";
- }
- }
-
- if(count($errors)){
- foreach($errors as $error){
- echo $error."\n";
- }
- die("Did not pass validation \n");
- }
-
- //do some mop specific validation
- $tNames = array();
- $fNames = array();
- $localFNames = array();
- $components = array();
- foreach(mop::config('objects', '//template') as $template){
- $name = $template->getAttribute('name');
- if(in_array($name, $tNames) || in_array($name, $fNames)){
- die("Duplicate Template Name: $name \n");
- }
- $tNames[] = $name;
-
- $localFNames = array();
- foreach(mop::config('objects', 'elements/*', $template) as $item){
- $name = null;
- switch($item->tagName){
-
- case 'list':
- $name = $item->getAttribute('family');
- break;
- }
-
- if($name){
- if(in_array($name, $tNames)){
- die("List family name cannot match template name: $name \n");
- }
- if(in_array($name, $localFNames)){
- die("List family cannot be repeated within template: $name \n");
- }
- $localFNames[] = $name;
- }
- }
-
- $fNames = array_merge($fNames, $localFNames);
-
- //check for components loops
- $comps = array();
- foreach(mop::config('objects','components/*', $template) as $component){
- $comps[] = $component->getAttribute('templateName');
- }
- if(in_array($name, $comps)){
- die("Component Loop in $name \n");
- } else {
- $components[$name] = $comps;
- }
- }
-
- //now check for cycles in $components
- foreach($components as $name => $comps){
- //may need a recursive function
- }
-
-
- echo "\nYou are attached to database ".Kohana::config('database.'.Database::instance_name($db).'.connection.database')."\n";
- // echo "Do you want to write template settings to this database - this will delete all previous templates ? (Yes/no)";
- flush();
- ob_flush();
- // $this->scanf('%s', $response);
- echo "Truncating templates table \n";
- flush();
- ob_flush();
- $db->query('delete from templates');
- $db->query('delete from objectmaps');
- $db->query('alter table templates AUTO_INCREMENT = 1');
- $db->query('alter table objectmaps AUTO_INCREMENT = 1');
-
-
- //build templates
- foreach(mop::config('objects', '//template') as $template){
- cms::configureTemplate($template);
- }
-
- exit;
-
- }
-
- private function valueIfSet($key, $array, $default=null){
- if(isset($array[$key])){
- return $array[$key];
- } else if($default) {
- return $default;
- } else {
- return null;
- }
- }
-
-
- public function scanf($format, &$a0=NULL, &$a1=NULL, &$a2=NULL, &$a3=NULL,
- &$a4=NULL, &$a5=NULL, &$a6=NULL, &$a7=NULL)
- {
- $num_args = func_num_args();
- if($num_args > 1) {
- $inputs = fscanf(STDIN, $format);
- for($i=0; $i<$num_args-1; $i++) {
- $arg = 'a'.$i;
- $$arg = $inputs[$i];
- }
- }
- }
-
-
-}
View
293 modules/tools/controllers/dumper.php
@@ -1,293 +0,0 @@
-<?
-
-class dumper_Controller extends Controller {
-
-
- public function __construct(){
- if(!is_writable('application/views/xmldumps/')){
- // die('application/views/xmldumps/ must be writable');
- }
- }
-
- private function getObjectFields($object){
- $fields = array();
- $content = $object->getContent();
- foreach($content as $key=>$value){
- if($key=='templateName'){
- continue;
- }
- $field = $this->doc->createElement($key);
- //print_r($value);
- if(is_array($value)){
-
- } else if(is_object($value)){
- switch(get_class($value)){
- case 'File_Model':
- //or copy to directory and just use filename
- if($value->fullpath){
- $field->appendChild( $this->doc->createTextNode($value->fullpath));
- }
- break;
- case 'Page_Model':
- foreach($this->getObjectFields($value) as $subField){
- $field->appendChild($subField);
- }
- break;
- }
- } else {
- $field->appendChild( $this->doc->createTextNode($value));
- }
- $fields[] = $field;
- }
- return $fields;
- }
-
- private function getObjectFieldsMOPFormat($object){
- $fields = array();
- $content = $object->getContent();
- foreach($content as $key=>$value){
- if($key=='templateName' || $key == 'dateadded'){
- continue;
- }
- if($key=="slug" && $value=""){
- continue;
- }
- $field = $this->doc->createElement('field');
- $fieldAttr = $this->doc->createAttribute('name');
- $fieldValue = $this->doc->createTextNode($key);
- $fieldAttr->appendChild($fieldValue);
- $field->appendChild($fieldAttr);
- //print_r($value);
- if(is_array($value)){
-
- } else if(is_object($value)){
- switch(get_class($value)){
- case 'File_Model':
- //or copy to directory and just use filename
- if($value->fullpath){
- $field->appendChild( $this->doc->createTextNode($value->fullpath));
- }
- break;
- case 'Page_Model':
- foreach($this->getObjectFields($value) as $subField){
- //$field->appendChild($subField);
- echo "sub objects not yet supported for mop export\n";
- }
- break;
- }
- } else {
- $field->appendChild( $this->doc->createTextNode($value));
- }
- $fields[] = $field;
- }
- return $fields;
- }
-
- private function exportTier($objects){
-
- $nodes = array();
- foreach($objects as $object){
- $item = $this->doc->createElement($object->template->templatename);
-
- foreach($this->getObjectFields($object) as $field){
- $item->appendChild($field);
- }
-
- //and get the children
- $childObjects = ORM::Factory('page')
- ->where('activity IS NULL')
- ->where('published = 1')
- ->where('parentid', $object->id)
- ->find_all();
- foreach($this->exportTier($childObjects) as $childItem){
- $item->appendChild($childItem);
- }
- $nodes[] = $item;
- }
-
- return $nodes;
- }
-
- private function exportTierMOPFormat($objects){
-
- $nodes = array();
- foreach($objects as $object){
- $item = $this->doc->createElement('item');
- $templateAttr = $this->doc->createAttribute('templateName');
- $templateValue = $this->doc->createTextNode($object->template->templatename);
- $templateAttr->appendChild($templateValue);
- $item->appendChild($templateAttr);
-
- foreach($this->getObjectFieldsMOPFormat($object) as $field){
- $item->appendChild($field);
- }
-
- //and get the children
- $childObjects = ORM::Factory('page')
- ->where('activity IS NULL')
- ->where('published = 1')
- ->where('parentid', $object->id)
- ->find_all();
- foreach($this->exportTierMOPFormat($childObjects) as $childItem){
- $item->appendChild($childItem);
- }
- $nodes[] = $item;
- }
-
- return $nodes;
- }
-
-
- public function exportMOPFormat($xslt=''){
- //get directory listing of application/media
-
- $this->doc = new DOMDocument('1.0', 'UTF-8');
- $this->doc->formatOutput = true;
- $data = $this->doc->createElement('data');
-
- $objects = ORM::Factory('page')
- ->where('activity IS NULL')
- ->where('published', 1)
- ->where('parentid', 0)
- ->find_all();
-
- foreach($this->exportTierMOPFormat($objects) as $item){
- $data->appendChild($item);
- }
- $this->doc->appendChild($data);
-
-
- $this->doc->save('application/media/export.xml');
-
- }
-
-
- public function export($xslt=''){
- //get directory listing of application/media
-
- $this->doc = new DOMDocument('1.0', 'UTF-8');
- $this->doc->formatOutput = true;
- $data = $this->doc->createElement('data');
-
- $objects = ORM::Factory('page')
- ->where('activity IS NULL')
- ->where('published', 1)
- ->where('parentid', 0)
- ->find_all();
-
- foreach($this->exportTier($objects) as $item){
- $data->appendChild($item);
- }
-
- $this->doc->appendChild('data');
- $this->doc->save('application/media/export.xml');
-
- exit;
- //echo ')))'.$item->getAttribute('templateName');
- $data = array();
- foreach(mop::config($xmlFile, 'field', $item ) as $content){
- $field = $content->getAttribute('name');
- //echo 'This Fielad '.$field."\n\n";
- switch($field){
- case 'title':
- $data[$field] = $content->nodeValue;
- continue(2);
- case 'slug':
- $data[$field] = $content->nodeValue;
- $data['decoupleSlugTitle'] = 1;
- continue(2);
- default:
- $data[$field] = $content->nodeValue;
- break;
- }
-
-
- //need to look up field and switch on field type
- $fieldInfo = mop::config('objects', sprintf('//template[@name="%s"]/elements/*[@field="%s"]', $item->getAttribute('templateName'), $content->getAttribute('name')))->item(0);
- if(!$fieldInfo){
- die("Bad field in builder!\n". sprintf('//template[@name="%s"]/elements/*[@field="%s"]', $item->getAttribute('templateName'), $content->tagName));
- }
- //echo "\ntagname\t".$fieldInfo->tagName."\n";
-
- //special setup based on field type
- switch($fieldInfo->tagName){
- case 'file':
- case 'image':
- $path_parts = pathinfo($content->nodeValue);
- $savename = cms::makeFileSaveName($path_parts['basename']);
- if(file_exists($content->nodeValue)){
- copy(str_replace('index.php', '', $_SERVER['SCRIPT_FILENAME']).$content->nodeValue, cms::mediapath($savename).$savename);
- } else {
- echo "File does not exist {$content->nodeValue} \n";
- die();
- }
- $data[$field] = $savename;
- break;
- default:
- $data[$field] = $content->nodeValue;
- break;
- }
-
- }
- $data['published'] = true;
- //echo 'parent'.$parentId;
- //print_r($data);
-
-
- foreach(mop::config($xmlFile, 'object', $item) as $object){
- $clusterData = array();
- foreach(mop::config($xmlFile, 'field', $object) as $clusterField){
- $clusterData[$clusterField->getAttribute('name')] = $clusterField->nodeValue;
- }
- $data[$object->getAttribute('name')] = $clusterData;
- }
-
-
- //now we check for a title collision
- //if there is a title collision, we assume that this is a component
- //already added at the next level up, in this case we just
- //update the objects data
- $existing = ORM::Factory('page')
- ->where('parentid', $parentId)
- ->find_all();
- $component = null;
- foreach($existing as $aComponent){
- //echo "\n\n".$aComponent->contenttable->title;
- if(isset($data['title'])){
- if($aComponent->contenttable->title == $data['title']){
- $component = $aComponent;
- break;
- }
- }
- }
- if($component){
- $component->updateWithArray($data);
- $objectId = $component->id;
- } else {
- $objectId = cms::addObject($parentId, $item->getAttribute('templateName'), $data);
- $this->newObjectIds[] = $objectId;
- }
-
- //do recursive if it has children
- if(mop::config($xmlFile, 'item', $item)->length ){
- $this->insertData($xmlFile, $objectId, $item);
- }
-
- foreach(mop::config($xmlFile, 'list', $item) as $list){
- //echo "FOUND A LIST\n\n";
- //find the container
- $listT = ORM::Factory('template', $list->getAttribute('family'));
- $container = ORM::Factory('page')
- ->where('parentid', $objectId)
- ->where('template_id', $listT->id)
- ->find();
- //jump down a level to add object
- $this->insertData($xmlFile, $container->id, $list);
- }
-
- }
-
- //and regenerate all files
- }
-
-}
View
172 modules/tools/controllers/frontend.php
@@ -1,172 +0,0 @@
-<?
-set_error_handler(array('Cli', 'error_handler'), E_ALL);
-
-Class Frontend_Controller extends Controller {
-
- private $basePath = 'application/views/generated/';
-
- public function __construct(){
- if(!is_writable($this->basePath)){
- die($this->basePath.' must be writable');
- }
- parent::__construct();
- }
-
- public function index(){
- echo "Configuring Frontend\n";
- echo "Reading application/config/frontend.xml\n";
-
- mop::config('objects', '//templates');
-
- flush();
-
- foreach(mop::config('frontend', '//view') as $view ){
- ob_start();
- touch($this->basePath.$view->getAttribute('name').'.php');
-
- if($view->getAttribute('loadPage')=='true'){
- echo "<h1><?=\$content['main']['title'];?></h1>\n\n";
- //this also implies that name is a templatename
- foreach(mop::config('objects',
- sprintf('//template[@name="%s"]/elements/*', $view->getAttribute('name') )) as $element){
- frontend::makeHtmlElement($element, "\$content['main']");
- }
- }
-
-
- //Now the includeData
- if($iDataNodes = mop::config('frontend',"//view[@name=\"".$view->getAttribute('name')."\"]/includeData")){
- foreach($iDataNodes as $iDataConfig){
- $prefix = "\$content";
- $this->makeIncludeDataHtml($iDataConfig, $prefix, null);
- }
- }
-
- if($subviews = mop::config('frontend',"//view[@name=\"".$view->getAttribute('name')."\"]/subview")){
- foreach($subviews as $subviewConfig){
- echo "\n<?=\$".$subviewConfig->getAttribute('label').";?>\n";
- }
- }
-
-
-
- $html = ob_get_contents();
- ob_end_clean();
- $file = fopen($this->basePath.$view->getAttribute('name').'.php', 'w');
- fwrite($file, $html);
- fclose($file);
- }
-
-
-
- echo "Done\n";
- }
-
- public function makeIncludeDataHtml($iDataConfig, $prefix, $parentTemplate, $indent=''){
- $label = $iDataConfig->getAttribute('label');
-
- $templates = array();
- //if slug defined, get template from slug
- if($slug = $iDataConfig->getAttribute('slug')){
- $object = ORM::Factory('page', $slug);
- if(!$object->loaded){
- //error out,
- //object must be loaded from data.xml for this type of include conf
- }
- $templates[] = $object->template->templatename;
- }
- if(!count($templates)){
- $templates = $iDataConfig->getAttribute('templateFilter');
- if($templates!='all'){
- $templates = explode(',', $templates);
- } else {
- $templates = array();
- }
- }
- if(!count($templates)){
- //no where for templates
- //assume that we'll have to make a good guess based off 'from' parent
- $from=$iDataConfig->getAttribute('from');
- if($from=="parent"){
-
- //get the info from addableObjects of the current
- foreach(mop::config('objects', sprintf('//template[@name="%s"]/addableObject', $parentTemplate)) as $addable){
- $templateName = $addable->getAttribute('templateName');
- $templates[$templateName] = $templateName;
- }
-
- //and we can also check all the existing data to see if it has any other templates
- $parentObjects = ORM::Factory('page')->templateFilter($parentTemplate)->publishedFilter()->find_all();
- foreach($parentObjects as $parent){
- $children = $parent->getPublishedChildren();
- foreach($children as $child){
- $templateName = $child->template->templatename;
- $templates[$templateName] = $templateName;
- }
- }
- } else {
- //see if from is a slug
- $object = ORM::Factory('page', $from);
- if($object->loaded){
- //find its addable objects
- foreach(mop::config('objects', sprintf('//template[@name="%s"]/addableObject', $object->template->templatename)) as $addable){
- $templateName = $addable->getAttribute('templateName');
- $templates[$templateName] = $templateName;
- }
- //and follow up with any existing data
- $children = $object->getPublishedChildren();
- foreach($children as $child){
- $templateName = $child->template->templatename;
- $templates[$templateName] = $templateName;
- }
- }
- }
- }
-
- // now $templates contains all the needed templates in the view
- echo $indent."<h2>$label</h2>\n\n";
-
- $doSwitch = false;
- if(count($templates)>1){
- $doSwitch = true;
- }
-
- echo $indent."<ul id=\"$label\" >\n";
- echo $indent."<?foreach({$prefix}['$label'] as \${$label}Item):?>\n";
- if($doSwitch){
- echo $indent." <?switch(\${$label}Item['templateName']){?>\n";
- }
-
- foreach($templates as $templateName){
- if($doSwitch){
- echo $indent."<? case '$templateName':?>\n";
- }
- echo $indent." <li class=\"$templateName\">\n";
- echo $indent." "."<h2><?=\${$label}Item['title'];?></h2>\n\n";
- foreach(mop::config('objects',
- sprintf('//template[@name="%s"]/elements/*', $templateName )) as $element){
- frontend::makeHtmlElement($element, "\${$label}Item", $indent." ");
- }
-
- //handle lower levels
- foreach(mop::config('frontend', 'includeData', $iDataConfig) as $nextLevel){
- $this->makeIncludeDataHtml($nextLevel, "\${$label}Item", $templateName, $indent." ");
- }
-
- echo $indent." </li>\n";
- if($doSwitch){
- echo $indent."<? break;?>\n";
- }
- }
- if($doSwitch){
- echo $indent."<? }?>\n";
- }
-
-
- echo $indent."<?endforeach;?>\n".
- $indent."</ul>\n\n";
-
-
- }
-
-}
View
42 modules/tools/controllers/mopsetup.php
@@ -1,42 +0,0 @@
-<?
-
-class mopSetup_Controller extends Controller {
-
-
- public function buildFrontendTemplates ($template=null) {
-
- $setup = Kohana::config('cms.templates');
- if($template){
- $filtered = array();
- $filtered[$template] = $setup[$template];
- $setup = $filtered;
- }
-
- foreach($setup as $templatename => $items){
- $tfile = fopen('application/modules/site/views/site/'.$templatename.'.php', 'w');
- foreach($items as $item){
- if($item['type'] == 'module'){
- if(isset($item['controllertype']) && ($item['controllertype'] == 'listmodule') ){
- $output = '<ul id="'.$item['modulename'].'">'."\n";
- $output .= '<?for($i=0, $count=count($content['."'".$item['modulename']."'".']), $firstlast=" class=\"first\""; $i<$count && $item=$content['."'".$item['modulename']."'".'][$i]; $i++, $i<$count-1?$firstlast="":$firstlast=" class=\"last\""):?>'."\n";
- $output .= '<li<?=$firstlast;?>>'."\n";
- foreach(Kohana::config($item['modulename'].'.fields') as $field=>$map){
- $output .= '<?=$item['."'".$field."'".'];?>'."\n";
- }
- $output .= '</li>'."\n";
- $output .= '<?endfor;?>'."\n";
- $output .= "</ul>\n";
- fwrite($tfile, $output."\n");
- }
-
- } else {
- fwrite($tfile, '<?=$content['."'".$item['field']."'".'];?>'."\n");
- }
- }
- /*
- * fwrite($tfile, '<?print_r($content);?>');
- */
- fclose($tfile);
- }
- }
-}
View
47 modules/tools/controllers/testbed.php
@@ -1,47 +0,0 @@
-<?
-
-Class TestBed_Controller extends Controller {
-
- public function __construct(){
- //sanity checks
- $notSane = null;
- if(!Kohana::config('testbed.dbPrefix')){
- $notSane .= "testbed.dbPrefix is not set: This configuration must be set in the config/testbed.php file to indicate the global database name prefix for the project\n";
- }
-
- if(!is_array(Kohana::config('testbed.tablesToRevert'))
- || !count(Kohana::config('testbed.tablesToRevert'))){
- $notSane .= "test.tablesToRevert is empty: This configuration muest be set in the config/testbed.php file to indicate which tables to copy back from the testbed database\n";
- }
- if($notSane){
- die(nl2br($notSane));
- }
-
- $this->testDatabase = Kohana::config('testbed.dbPrefix').'test.';
- $this->testbedDatabase = Kohana::config('testbed.dbPrefix').'testbed.';
- parent::__construct();
- }
-
- public function index(){
- $this->view = new View('testbedIndex');
- $this->view->render(true);
- exit;
- }
-
-
- public function revertTestingData(){
- $db = new Database();
- //drop tables
- foreach(Kohana::config('testbed.tablesToRevert') as $table){
- $db->query('drop table if exists '.$this->testDatabase.$table);
- }
- //get data from testarea
- foreach(Kohana::config('testbed.tablesToRevert') as $table){
- $db->query('create table '.$this->testDatabase.$table.' like '.$this->testbedDatabase.$table);
- $db->query('insert into '.$this->testDatabase.$table.' select * from '.$this->testbedDatabase.$table);
- }
- echo 'done';
- exit;
-
- }
-}
View
22 modules/tools/controllers/tests.php
@@ -1,22 +0,0 @@
-<?
-Class Tests_Controller extends Controller {
-
- public function imagesize($imageFileName){
- $imageFileName = str_replace("'", '', $imageFileName);
- $imageFileName = str_replace('&#039;', '', $imageFileName);
- $dimensions = getimagesize('application/media/'.$imageFileName);
- $width = $dimensions[0];
- $height = $dimensions[1];
- echo <<<EOT
-<html>
- <body>
- <ul>
- <li id="width">$width</li>
- <li id="height">$height</li>
- </ul>
- </body>
-</html>
-EOT;
- }
-
-}
View
7 modules/usermanagement/config/cms.php
@@ -1,7 +0,0 @@
-<?
-
-/*
- * Config: ['usermanagement']['defaultsettings']['editable_title']
- * Default settings for usermanagement module deployment in cms
- */
-$config['usermanagement']['defaultsettings']['editable_title'] = false;
View
225 modules/usermanagement/controllers/usermanagement.php
@@ -1,225 +0,0 @@
-<?
-/*
- * Class: UserManagement_Controllers
- * Controller for usermangement module within MoPCMS, allows for settings up users
- * and passwords. Can be configured deal with roles using the managedroles variables.
- */
-
-Class UserManagement_Controller extends Controller {
-
- /*
- * Variable: model
- * Defines the database table where users are stored
- */
- protected $table = 'user';
-
- /*
- * Variable: viewName
- * Name of the main view to load, also used for javascript class and instance.
- */
- protected $viewName = 'usermanagement';
-
- /*
- * Variable: managedRoles
- * Roles set up in the config file are loaded into this class variable
- */
- protected $managedRoles;
-
- /*
- * Function: __construct()
- * Loads managedRoles and calls the parent constructor
- */
- public function __construct(){
- parent::__construct();
-
- $this->managedRoles = Kohana::config(strtolower($this->controllername).'.managedRoles');
-
- }
-
- /*
- * Function: createIndexView()
- * Subclassed function to build the top view
- * Parameters: none
- * Returns: nothing, sets up view to render in this->view
- */
- public function createIndexView(){
- //cleanup on an initial load
- $incompletes = ORM::Factory($this->table)->where('status', 'INCOMPLETE')->find_all();
- foreach($incompletes as $incomplete){
- $incomplete->delete();
- }
-
- $this->view = new View($this->viewName);
- $this->view->instance = $this->viewName;
- $this->view->class = $this->viewName;
-
- $users = ORM::Factory($this->table)->find_all();
- $html = '';
- foreach($users as $user){
- $usertemplate = new View($this->viewName.'_item');
- $data['id'] = $user->id;
- $data['username'] = $user->username;
- $data['email'] = $user->email;
-
- if(strlen($user->password)){
- $data['password'] = '******';
- } else {
- $data['password'] = '';
- }
-
- //find role'] = null;
- $data['role'] = null;
- foreach($this->managedRoles as $label=>$role){
- if($user->has(ORM::Factory('role', $role))){
- $data['role'] = $role;
- }
- }
-
- $usertemplate->data = $data;
-
- $usertemplate->managedRoles = $this->managedRoles;
- $html .= $usertemplate->render();
- }
-
- $this->view->items = $html;
-
- }
-
- /*
- * Function: addItem($pageid)
- * Ajax interface to add a new user object to the users table.
- * Parameters:
- * $pageid - unused variable, interface needs to be updated
- * Returns: Rendered html editing page for new user object
- */
- public function addItem($pageid){
- $user = $this->createUser();
- $data = $user->as_array();
-
- //set no managedRole
- $data['role'] = null;
-
- $this->view = new View($this->viewName.'_item');
- $this->view->data = $data;
- $this->view->managedRoles = $this->managedRoles;
- return $this->view->render();
- }
-
- /*
- * Function: createUser()
- * Utility function to create an empty user object in the database, with status INCOMPLETE
- * and placeholder content for username and email
- * Parameters: none
- * Returns: User ORM Object, pre-saved
- */
- protected function createUser(){
- $user = ORM::factory($this->table);
- $user->status = 'INCOMPLETE';
- $user->username = 'PLACEHOLDER_'.microtime();
- $user->email = 'PLACEHOLDER_'.microtime();
- $user->save();
-
- //add the login role
- $user->add(ORM::Factory('role', 'login'));
- $user->add(ORM::Factory('role', 'admin'));
- $user->add(ORM::Factory('role', 'staging'));
- $user->save();
-
- return $user;
-
- }
-
- /*
- * Function: deleteItem($id)
- * Deletes a user from the database
- * Parameters:
- * $id - the unique key id of the record to delete
- * Returns: nothing
- */
- public function deleteItem($id){
- $user = ORM::factory($this->table, $id);
- $user->delete($id);
-
- }
-
- /*
- * Function: saveField($id)
- * Ajax interface to update a field in the database table with a new value
- * Parameters:
- * $id - the unique key id of the record to update
- * $_POST['field'] - the field to update
- * $_POST['value'] - the new value to save
- * Returns: array('value'=>{value})
- */
- public function saveField($id){
- $user = ORM::factory($this->table, $id);
-
- switch($_POST['field']){
- case 'role':
- //first remove other managedRoles
- foreach($this->managedRoles as $label => $role){
- $roleObj = ORM::Factory('role', $role);
- if($user->has($roleObj)){
- $user->remove($roleObj);
- }
- }
- $user->add(ORM::Factory('role', $_POST['value']));
- $user->save();
- $return = array('value'=>$_POST['value']);
- break;
-
- default:
-
- $errors = $user->checkValue($_POST['field'], $_POST['value']);
- Kohana::log('info', 'return from errors '.var_export($errors, true) );
- if(!$errors){
- $user->$_POST['field'] = $_POST['value'];
- $user->save();
-
- //this might be the first edit on a new record
- //so set the record to active status
- $this->activateRecord($user);
-
-
- if($_POST['field'] == 'password'){
- $body = new View('usermanagement_passwordchangeemail');
- $body->username = $user->username;
- $body->password = $_POST['value'];
-
- mail($user->email, Kohana::config('usermanagement.passwordchangeemail.subject'), $body->render());
- $md5 = $user->password;
- $return = array('value'=>$md5);
- } else {
- $return = array('value'=>$_POST['value']);
- }
- } else {
- $firstkey = array_keys($errors);
- $firstkey = $firstkey[0];
- if($_POST['field']=='password'){
- $rval = null;
- } else {
- $rval = $_POST['value'];
- }
- $return = array('value'=>$rval, 'error'=>'true', 'message'=>$errors[$firstkey]);
- }
- break;
- }
- return $return;
-
- }
-
- /*
- * Function: activateRecord(& $user)
- * Switches a user record from status INCOMPLETE to status ACTIVE
- * Parameters:
- * $user - an ORM object to update
- * Returns: nothing
- */
- protected function activateRecord(& $user){
- if($user->status == 'INCOMPLETE'){
- $user->status = 'ACTIVE';
- $user->save();
- }
- }
-
-}
View
0  staging/application/media/.gitignore
No changes.
Please sign in to comment.
Something went wrong with that request. Please try again.