Skip to content
Browse files

Keep track of all uncommitted files

  • Loading branch information...
1 parent 8745aac commit 79c7eb50dd6e02757556265624080f810040c392 @quincykwende quincykwende committed
Showing with 2,810 additions and 9,001 deletions.
  1. +0 −249 classes/associator.php
  2. +0 −31 classes/associator/checkboxes.php
  3. +0 −31 classes/associator/radios.php
  4. +2 −310 classes/builder/frontend.php
  5. +2 −8 classes/controller/accessdenied.php
  6. +3 −177 classes/controller/ajax.php
  7. +1 −1 classes/controller/associator.php
  8. +3 −174 classes/controller/auth.php
  9. +3 −14 classes/controller/authstatus.php
  10. +3 −314 classes/controller/builder.php
  11. +2 −36 classes/controller/cms.php
  12. +2 −287 classes/controller/csv.php
  13. +2 −41 classes/controller/csvimports.php
  14. +2 −340 classes/controller/customreel.php
  15. +2 −257 classes/controller/export.php
  16. +2 −66 classes/controller/file.php
  17. +3 −10 classes/controller/footer.php
  18. +2 −29 classes/controller/graph.php
  19. +3 −10 classes/controller/header.php
  20. +2 −9 classes/controller/headerfooter.php
  21. +0 −16 classes/controller/html.php
  22. +2 −10 classes/controller/initializer.php
  23. +11 −9 classes/controller/keepalive.php
  24. +2 −19 classes/controller/language.php
  25. +0 −160 classes/controller/lattice.php
  26. +3 −106 classes/controller/latticeviews.php
  27. +0 −76 classes/controller/layout.php
  28. +3 −212 classes/controller/list.php
  29. +2 −194 classes/controller/navigation.php
  30. +6 −5 classes/controller/preview.php
  31. +2 −65 classes/controller/publicmenu.php
  32. +2 −2 classes/controller/registration.php
  33. +6 −0 classes/controller/rest.php
  34. +2 −19 classes/controller/setup.php
  35. +8 −8 classes/controller/test.php
  36. +3 −335 classes/controller/usermanagement.php
  37. +2 −8 classes/controller/views.php
  38. +6 −0 classes/controller/xml.php
  39. +0 −44 classes/frontend.php
  40. +2 −217 classes/graph.php
  41. +2 −81 classes/graph/objectquery.php
  42. +2 −13 classes/initializer/cms.php
  43. +2 −27 classes/initializer/lattice.php
  44. +0 −57 classes/initializer/latticeauth.php
  45. +0 −264 classes/lattice.php
  46. +2 −258 classes/lattice/cms.php
  47. +2 −340 classes/lattice/cmsinterface.php
  48. +2 −68 classes/lattice/controller/associator.php
  49. +2 −109 classes/lattice/initializer.php
  50. +0 −122 classes/latticeauth/controller/registration.php
  51. +0 −368 classes/latticecms.php
  52. +0 −197 classes/latticeui.php
  53. +0 −9 classes/latticeurl.php
  54. +0 −152 classes/latticeutil.php
  55. +0 −368 classes/latticeview.php
  56. +5 −4 classes/model/association.php
  57. +4 −6 classes/model/content.php
  58. +70 −61 classes/model/file.php
  59. +5 −6 classes/model/initializedmodule.php
  60. +10 −8 classes/model/language.php
  61. +6 −4 classes/model/lattice.php
  62. +22 −21 classes/model/lattice/contentdriver.php
  63. +44 −38 classes/model/lattice/foreign.php
  64. +175 −137 classes/model/lattice/object.php
  65. +50 −43 classes/model/listcontainer.php
  66. +1,815 −1,524 classes/model/object.php
  67. +2 −3 classes/model/objectelementrelationship.php
  68. +60 −54 classes/model/objectmap.php
  69. +2 −12 classes/model/objectrelationship.php
  70. +1 −8 classes/model/objects/tag.php
  71. +1 −9 classes/model/objects/user.php
  72. +189 −163 classes/model/objecttype.php
  73. +1 −9 classes/model/rosetta.php
  74. +1 −7 classes/model/tag.php
  75. +12 −12 classes/model/user.php
  76. +0 −61 classes/navigation.php
  77. +9 −7 classes/response.php
  78. +13 −11 classes/session.php
  79. +0 −39 classes/utility/auth.php
  80. +0 −135 classes/view/csv.php
  81. +0 −36 classes/view/csvcontainer.php
  82. +1 −1 config/auth.php
  83. +0 −4 config/cms-s.php
  84. +5 −5 config/cms.php
  85. +3 −3 config/lattice.php
  86. +6 −6 config/lattice_cms.php
  87. +1 −1 config/latticeviews.php
  88. +4 −4 config/navigation.php
  89. +2 −2 config/registration.php
  90. +9 −10 config/usermanagement.php
  91. +0 −48 cookbook/moplib.htaccess
  92. +4 −4 devtools/ruckusing-migrations/config/config.inc.php
  93. +6 −6 devtools/ruckusing-migrations/generate.php
  94. +95 −95 devtools/ruckusing-migrations/lib/classes/adapters/class.Ruckusing_MySQLAdapter.php
  95. +31 −31 devtools/ruckusing-migrations/lib/classes/adapters/class.Ruckusing_MySQLTableDefinition.php
  96. +20 −20 devtools/ruckusing-migrations/lib/classes/class.Ruckusing_FrameworkRunner.php
  97. +8 −8 devtools/ruckusing-migrations/lib/classes/task/class.Ruckusing_TaskManager.php
  98. +3 −3 devtools/ruckusing-migrations/lib/classes/util/class.Ruckusing_Logger.php
Sorry, we could not display the entire diff because it was too big.
View
249 classes/associator.php
@@ -1,249 +0,0 @@
-<?
-/* @package Lattice */
-
-Class Associator {
-//mainassociator
- public $parentId = NULL;
- public $parent = NULL;
- public $lattice = NULL;
- public $filters = NULL;
- public $pool = array();
- public $associated = array();
- //set this as needed when calling paged results
- //right now this is set on an instance, by actions that pre load $this->pool
- public $numPages = 2;
-
- protected $label;
- protected $poolLabel;
- protected $pageLength;
- //this is page size for paginator
- //this doesn't matter anymore because we're paginating
- private $maxPoolSize = 80;
- private $pageNum = 1;
- public static function getFiltersFromDomNode($node){
- $filtersNodeList = lattice::config('objects', 'filter', $node);
- $filters = array();
- foreach($filtersNodeList as $filter){
- $setting = array();
- $setting['from'] = $filter->getAttribute('from');
- $setting['objectTypeName'] = $filter->getAttribute('objectTypeName');
- $setting['tagged'] = $filter->getAttribute('tagged');
- $setting['function'] = $filter->getAttribute('function');
- $filters[] = $setting;
- }
- return $filters;
-
- }
-
-
- //TODO
- public function setViewName($viewName){throw new Kohana_Exception('Not Implemented');} //to support multi-lattice single custom view
- public function setAssociatorName($associatorName){throw new Kohana_Exception('Not Implemented');} //to support mutli-instance single lattice
-
-
-
- public function __construct($parentId, $lattice, $filters=NULL, $loadPool=NULL){
- $this->parentId = $parentId;
- $this->parent = Graph::object($this->parentId);
- $this->lattice = $lattice;
- $this->filters = $filters;
- $this->pageLength = Kohana::config('cms.associatorPageLength');
-
- foreach($this->parent->getLatticeChildrenPaged($this->lattice) as $child){
- $this->associated[] = $child;
- }
-
- if(is_array($loadPool)){
- $this->pool = $loadPool;
- }
- $logPool = array();
-
- if (is_array($loadPool)){
- foreach ($loadPool as $l){
- $logPool[] = $l->id;
- }
-
- }
- // Kohana::$log->add( Kohana_Log::INFO, print_r($logPool,1) )->write();
- // Kohana::$log->add( Kohana_Log::INFO, print_r($filters,1) )->write();
- // Kohana::$log->add( Kohana_Log::INFO, print_r($lattice,1) )->write();
-
- //load pool
- if($filters){
-
- $objects = Graph::object();
-
- foreach($filters as $filter){
-
- if(isset($filter['from']) && $filter['from']){
- $from = Graph::object($filter['from']);
- ($filter['lattice']) ? $lattice = $filter['lattice'] : $lattice = 'lattice';
- $objects = $from->latticeChildrenQuery($lattice);
- }
-
- if(isset($filter['tagged']) && $filter['tagged']){
- $objects->taggedFilter($filter['tagged']);
- }
-
- if(isset($filter['objectTypeName']) && $filter['objectTypeName']){
- $t = ORM::Factory('objectType', $filter['objectTypeName']);
- if(!$t->loaded()){
- Graph::configureObjectType($filter['objectTypeName']);
- $t = ORM::Factory('objecttype', $filter['objectTypeName']);
- if(!$t->loaded()){
- throw new Kohana_Exception($filter['objectTypeName'] .' Not Found');
- }
- }
- $objects->where('objecttype_id', '=', $t->id);
- }
-
- if(isset($filter['match']) && $filter['match']){
- $matchFields = explode(',',$filter['matchFields']);
- $wheres = array();
- foreach($matchFields as $matchField){
- $wheres[] = array($matchField, 'LIKE', '%'.$filter['match'].'%');
- }
- $objects->contentFilter($wheres);
-
- }
-
- if(isset($filter['function']) && $filter['function']){
- $callback = explode('::', $filter['function']);
-
- $options = null;
- $objects = call_user_func($callback, $objects, $parentId, $options);
- }
-
-
- $objects->where('objects.language_id', '=', Graph::defaultLanguage());
- $objects->publishedFilter();
- //just return an array of id's then load the pool object
- $results = $objects->find_all()->as_array(NULL, 'id');
- //check our filtered objects are correct
- //compact the array to remove redundant keys
- $res = array();
- foreach ($results as $id) {
- $object = Graph::object($id);
- if(!$this->parent->checkLatticeRelationship($lattice, $object)){
- $res[$id] = $id;
- }
- }
- $results = $res;
- $this->numPages = ceil(count($results)/$this->pageLength);
- //get slice the first page, then load the objects from their id's
- $params = explode("/",$_SERVER["REQUEST_URI"]);
- //print_r($params);
- //@TODO this is a kludge. Oh well.
- if (isset($params[7]) && $params[6]=="postingVideosAssociator"){
- //we're passing a page number - so slice the object ids
- $results = array_slice($results,($params[7]-1)*16,16);
- } else {
- $results = array_slice($results,0,$this->pageLength);
- }
-
- foreach($results as $id){
- $object = Graph::object($id);
- $this->pool[$id] =$object;
- }
- }
-
- } else if(!is_array($loadPool)) {
-
- $objects = Graph::object()
- ->where( 'id', '!=', $parentId )
- ->where( 'objects.language_id', '=', Graph::defaultLanguage() )
- ->publishedFilter()
- ->limit( $this->maxPoolSize )
- ->find_all();
- $this->pool = $objects;
-
- }
-
- }
-
- public function setLabel($label){
- $this->label = $label;
- }
- public function setPageLength($pageLength){
- $this->pageLength = $pageLength;
- }
-
- public function setPoolLabel($poolLabel){
- $this->poolLabel = $poolLabel;
- }
-
- public function render($viewName = NULL){
- if($viewName && ($view = Kohana::find_file('views', 'lattice/associator/'.$viewName) )){
- $view = new View('lattice/associator/'.$viewName);
- } else {
- $view = new View('lattice/associator');
- }
-
-
- $view->pool = $this->poolItemViews($viewName);
-
- $view->associated = array();
- foreach($this->associated as $associatedItem){
- $view->associated[] = $this->getItemView($associatedItem, $viewName);
- }
-
- $view->parentId = $this->parentId;
- $view->lattice = $this->lattice;
- $view->label = $this->label;
- $view->poolLabel = $this->poolLabel;
- $view->pageLength = $this->pageLength;
- $view->numPages = $this->numPages;
-
-
-
- /*
- paginator vars- probably should be its own func
- these are messy too
-
- */
-
- $view->urlPrepend = "ajax/html";
- // echo strpos($original_uri,$action);
- //pass our paginator params to the view
-// $view->controllerName = $this->request->controller();
-// $view->action = $action;
-// $view->params = $this->request->param();
-// $view->currentPage = $view->params["param4"];
- /* end paginator vars*/
- return $view->render();
- }
-
- public function renderPoolItems(){
- return( implode("\n",$this->poolItemViews($this->lattice) ) );
- }
-
- private function poolItemViews($viewName = NULL){
- $poolItemViews = array();
- foreach($this->pool as $poolItem){
- $poolItemViews[] = $this->getItemView($poolItem, $viewName);
- }
- return $poolItemViews;
- }
-
- private function getItemView($item, $viewName){
-
- if($viewName && $view = Kohana::find_file('views/lattice/associator/'.$viewName, $item->objecttype->objecttypename)){
- $view = new View('lattice/associator/'.$viewName.'/'.$item->objecttype->objecttypename);
- } else if($viewName && $view = Kohana::find_file('views/lattice/associator/'.$viewName, 'item')){
- $view = new View('lattice/associator/'.$viewName.'/'.'item');
- } else if($view = Kohana::find_file('views/lattice/associator/', $item->objecttype->objecttypename)){
- $view = new View('lattice/associator/'.$item->objecttype->objecttypename);
- } else {
- $view = new View('lattice/associator/item');
- }
- $view->object = $item;
-
- $view->selected = false;
-
- return $view;
-
- }
-
-
-
-}
View
31 classes/associator/checkboxes.php
@@ -1,31 +0,0 @@
-<?
-
-Class Associator_Checkboxes {
-
- public static function makePool($associatedViews, $poolViews){
- if(count($associatedViews)){
- $keys = array_map(array('Associator_Checkboxes','titleIndex'), $associatedViews);
- $associatedViews = array_combine($keys, $associatedViews);
- }
- $poolViews = array_combine( array_map(array('Associator_Checkboxes','titleIndex'), $poolViews), $poolViews);
- foreach($associatedViews as $key => $view){
- $view->selected = true;
- $poolViews[$key] = $view;
- }
-
- array_walk($poolViews, array('Associator_Checkboxes', 'setUniqueElementId'));
-
- ksort($poolViews);
-
- return $poolViews;
- }
-
- private static function titleIndex($view){
- return $view->object->title;
- }
-
- private static function setUniqueElementId($view){
- $view->uniqueElementId = LatticeCms::uniqueElementId();
- }
-
-}
View
31 classes/associator/radios.php
@@ -1,31 +0,0 @@
-<?
-
-Class Associator_Radios {
-
- public static function makePool($associatedViews, $poolViews){
- if(count($associatedViews)){
- $keys = array_map(array('Associator_Radios','titleIndex'), $associatedViews);
- $associatedViews = array_combine($keys, $associatedViews);
- }
- $poolViews = array_combine( array_map(array('Associator_Radios','titleIndex'), $poolViews), $poolViews);
- foreach($associatedViews as $key => $view){
- $view->selected = true;
- $poolViews[$key] = $view;
- }
-
- array_walk($poolViews, array('Associator_Radios', 'setUniqueElementId'));
-
- ksort($poolViews);
-
- return $poolViews;
- }
-
- private static function titleIndex($view){
- return $view->object->title;
- }
-
- private static function setUniqueElementId($view){
- $view->uniqueElementId = LatticeCms::uniqueElementId();
- }
-
-}
View
312 classes/builder/frontend.php
@@ -1,311 +1,3 @@
-<?
+<?php defined('SYSPATH') or die('No direct access allowed.');
-Class Builder_Frontend {
-
- private $basePath = 'application/views/generated/';
-
- public function __construct(){
- if(!is_writable($this->basePath)){
- die($this->basePath.' must be writable');
- }
- }
-
- public function index(){
- echo "Configuring Frontend\n";
- echo "Reading application/config/frontend.xml\n";
-
- lattice::config('objects', '//objectTypes');
-
- flush();
- ob_flush();
- flush();
-
- $createdViews = array();
- // foreach(lattice::config('frontend', '//view') as $view ){
- // //this has removed the ability to build virtual views
- foreach(lattice::config('objects', '//objectType') as $objectType){
- $view = lattice::config('frontend', '//view[@name="'.$objectType->getAttribute('name').'"]');
- if(count($view)){
- $view = $view->item(0);
- }
- if($view){
- $viewName = $view->getAttribute('name');
- } else {
- $viewName = $objectType->getAttribute('name');
- }
-
- echo $viewName."\n";
- flush();
- ob_flush();
- flush();
-
- ob_start();
- if(!$view || ($view && $view->getAttribute('loadPage')=='true')){
- echo "<h1><?=\$content['main']['title'];?></h1>\n\n";
- //this also implies that name is a objecttypename
- foreach(lattice::config('objects',
- sprintf('//objectType[@name="%s"]/elements/*', $viewName )) as $element){
-
- switch($element->tagName){
- case 'list':
- $this->makeListDataHtml($element, "\$content['main']");
- break;
- case 'associator':
- $this->makeAssociatorDataHtml($element, "\$content['main']");
- break;
- default:
- frontend::makeHtmlElement($element, "\$content['main']");
- break;
- }
-
- }
-
- if($view && $view->getAttribute('loadPage')=='true'){
-
- //Now the includeData
- if($iDataNodes = lattice::config('frontend',"//view[@name=\"".$view->getAttribute('name')."\"]/includeData")){
- foreach($iDataNodes as $iDataConfig){
- $prefix = "\$content";
- $this->makeIncludeDataHtml($iDataConfig, $prefix, null);
- }
- }
-
- if($subviews = lattice::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.$viewName.'.php', 'w');
- fwrite($file, $html);
- fclose($file);
-
- $createdViews[] = $viewName;
- }
- }
-
- echo 'Completed all basic object views' . "\n";
- flush();
- ob_flush();
- flush();
-
- //and any virtual views
- foreach(lattice::config('frontend', '//view') as $viewConfig){
- $viewName = $viewConfig->getAttribute('name');
-
- if( in_array($viewName, $createdViews)){
- continue;
- }
- echo 'Virtual View: '.$viewName . "\n";
- flush();
- ob_flush();
- flush();
-
-
- touch($this->basePath.$viewName.'.php');
-
- ob_start();
- //Now the includeData
-
- if($iDataNodes = lattice::config('frontend',"//view[@name=\"".$viewName."\"]/includeData")){
- foreach($iDataNodes as $iDataConfig){
- $prefix = "\$content";
- $this->makeIncludeDataHtml($iDataConfig, $prefix, null);
- }
- }
-
- if($subviews = lattice::config('frontend',"//view[@name=\"".$viewName."\"]/subview")){
- foreach($subviews as $subviewConfig){
- echo "\n<?=\$".$subviewConfig->getAttribute('label').";?>\n";
- }
- }
-
-
- $html = ob_get_contents();
- ob_end_clean();
- $file = fopen($this->basePath.$viewName.'.php', 'w');
- fwrite($file, $html);
- fclose($file);
- }
-
-
-
- echo "Done\n";
- }
-
- public function makeListDataHtml($listDataConfig, $prefix, $indent = ''){
- $objectTypes = array();
- foreach (lattice::config('objects', 'addableObject', $listDataConfig) as $addable) {
- $objectTypeName = $addable->getAttribute('objectTypeName');
- $objectTypes[$objectTypeName] = $objectTypeName;
- }
-
- $this->makeMultiObjectTypeLoop($objectTypes, $listDataConfig->getAttribute('name'), $prefix, $indent);
-
- }
-
- //TODO: This doesn't currently support filter types that don't declare objecTypeNames or
- //nor with multiple objectTypeNames per filter
- public function makeAssociatorDataHtml($associatorDataConfig, $prefix, $indent = ''){
- $objectTypes = array();
- $filters = lattice::config('objects', 'filter', $associatorDataConfig);
- foreach($filters as $filter){
- if($filter->getAttribute('objectTypeName')){
- $objectTypes[] = $filter->getAttribute('objectTypeName');
- }
- }
-
- $this->makeMultiObjectTypeLoop($objectTypes, $associatorDataConfig->getAttribute('name'), $prefix, $indent);
- }
-
-
- public function makeIncludeDataHtml($iDataConfig, $prefix, $parentTemplate, $indent=''){
- $label = $iDataConfig->getAttribute('label');
-
-
- $objectTypes = array();
- //if slug defined, get objectType from slug
- if($slug = $iDataConfig->getAttribute('slug')){
- $object = Graph::object($slug);
- if(!$object->loaded()){
- //error out,
- //object must be loaded from data.xml for this type of include conf
- }
- $objectTypes[] = $object->objecttype->objecttypename;
- }
- if(!count($objectTypes)){
- $objectTypes = $iDataConfig->getAttribute('objectTypeFilter');
- if($objectTypes!='all'){
- $objectTypes = explode(',', $objectTypes);
- } else {
- $objectTypes = array();
- }
- }
-
- if(!count($objectTypes)){
- //no where for objectTypes
- //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(lattice::config('objects', sprintf('//objectType[@name="%s"]/addableObject', $parentTemplate)) as $addable){
- $objectTypeName = $addable->getAttribute('objectTypeName');
- $objectTypes[$objectTypeName] = $objectTypeName;
- }
-
- //and we can also check all the existing data to see if it has any other objectTypes
- $parentObjects = Graph::object()->objecttypeFilter($parentTemplate)->publishedFilter()->find_all();
- foreach($parentObjects as $parent){
- $children = $parent->getPublishedChildren();
- foreach($children as $child){
- $objectTypeName = $child->objecttype->objecttypename;
- $objectTypes[$objectTypeName] = $objectTypeName;
- }
- }
- } else {
- //see if from is a slug
- $objectTypesFromParent = $this->getChildrenObjectTypes(Graph::object($from));
- $objectTypes = array_merge($objectTypes, $objectTypesFromParent);
-
-
- }
- }
-
- // now $objectTypes contains all the needed objectTypes in the view
-
-
- $this->makeMultiObjectTypeLoop($objectTypes, $label, $prefix, $indent, $iDataConfig);
- }
-
- protected function makeMultiObjectTypeLoop($objectTypes, $label, $prefix, $indent='', $frontendNode=NULL ){
- echo $indent."<h2>$label</h2>\n\n";
- echo $indent."<ul id=\"$label\" >\n";
- $doSwitch = false;
-
-
- if(count($objectTypes)>1){
- $doSwitch = true;
- }
-
- echo $indent."<?foreach({$prefix}['$label'] as \${$label}Item):?>\n";
- if($doSwitch){
- echo $indent." <?switch(\${$label}Item['objectTypeName']){\n";
- }
-
- if(count($objectTypes) == 0){
- echo $indent." <?=latticeview::Factory(\${$label}Item)->view()->render();?>\n";
- }
-
- $i=0;
- foreach ($objectTypes as $objectTypeName) {
- if ($doSwitch) {
- echo $indent;
- if($i==0)
- echo " case '$objectTypeName':?>\n";
- else
- echo " <? case '$objectTypeName':?>\n";
- }
- echo $indent . " <li class=\"$objectTypeName\">\n";
- echo $indent . " " . "<h2><?=\${$label}Item['title'];?></h2>\n\n";
- foreach (lattice::config('objects', sprintf('//objectType[@name="%s"]/elements/*', $objectTypeName)) as $element) {
- switch($element->tagName){
- case 'list':
- $this->makeListDataHtml($element, "\${$label}Item", $indent);
- break;
- case 'associator':
- $this->makeAssociatorDataHtml($element, "\${$label}Item", $indent);
- break;
- default:
- frontend::makeHtmlElement($element, "\${$label}Item", $indent . " ");
- break;
- }
- }
-
- //handle lower levels
- if ($frontendNode) {
- foreach (lattice::config('frontend', 'includeData', $frontendNode) as $nextLevel) {
- $this->makeIncludeDataHtml($nextLevel, "\${$label}Item", $objectTypeName, $indent . " ");
- }
- }
-
- echo $indent . " </li>\n";
- if ($doSwitch) {
- echo $indent . " <? break;?>\n";
- }
- $i++;
- }
- if ($doSwitch) {
- echo $indent . "<? }?>\n";
- }
-
-
- echo $indent . "<?endforeach;?>\n" .
- $indent . "</ul>\n\n";
- }
-
- protected function getChildrenObjectTypes($object){
- $objectTypes = array();
- if ($object->loaded()) {
- //find its addable objects
- foreach (lattice::config('objects', sprintf('//objectType[@name="%s"]/addableObject', $object->objecttype->objecttypename)) as $addable) {
- $objectTypeName = $addable->getAttribute('objectTypeName');
- $objectTypes[$objectTypeName] = $objectTypeName;
- }
- //and follow up with any existing data
- $children = $object->getPublishedChildren();
- foreach ($children as $child) {
- $objectTypeName = $child->objecttype->objecttypename;
- $objectTypes[$objectTypeName] = $objectTypeName;
- }
- }
- return $objectTypes;
-
- }
-}
+class Builder_Frontend extends Lattice_Builder_Frontend { }
View
10 classes/controller/accessdenied.php
@@ -1,12 +1,6 @@
-<?
+<?php
-Class Controller_AccessDenied extends Controller_Layout {
+Class Controller_Accessdenied extends Lattice_Controller_Accessdenied {
- public $_actionsThatGetLayout = array('index');
-
- public function action_index(){
- $view = new View('accessdenied');
- $this->response->body($view->render());
- }
}
View
180 classes/controller/ajax.php
@@ -1,180 +1,6 @@
<?php defined('SYSPATH') or die('No direct script access.');
-class Controller_Ajax extends Controller_Lattice {
+class Controller_Ajax extends Lattice_Controller_Ajax {
- public function action_index()
- {
- throw new HTTP_Exception_404('Ajax controller called without action. Check URL.');
- }
-
- private function handleException($e){
-
- // Get the exception information
- $type = get_class($e);
- $code = $e->getCode();
- $message = $e->getMessage();
- $file = $e->getFile();
- $line = $e->getLine();
-
- // Get the exception backtrace
- $trace = $e->getTrace();
-
- ob_start();
-
- // Include the exception HTML
- if ($view_file = Kohana::find_file('views', Kohana_Exception::$error_view))
- {
- include $view_file;
- }
- else
- {
- throw new Kohana_Exception('Error view file does not exist: views/:file', array(
- ':file' => Kohana_Exception::$error_view,
- ));
- }
-
- // Display the contents of the output buffer
- $message = ob_get_clean();
- return $message;
- }
-
- public function action_data($uri)
- {
- //request to child, just data
- $arguments = explode('/', $uri);
-
- try {
- $subRequest = Request::Factory($uri);
- $data = $subRequest->execute()->data();
- } catch (Exception $e) {
- //return HTML from exception
-
- // Start an output buffer
-
- $ajaxResponse = array(
- 'returnValue' => FALSE,
- 'response' => $this->handleException($e),
- 'arguments'=>$arguments
-
- );
- $this->response->headers('Content-Type', 'application/json');
- $this->response->body(json_encode($ajaxResponse));
- return;
- }
- $ajaxResponse = array(
- 'returnValue' => TRUE,
- 'response'=>$data,
- 'arguments'=>$arguments
- );
- $this->response->headers('Content-Type', 'application/json');
- $this->response->body(json_encode($ajaxResponse));
- $this->response->body();
- }
-
- public function action_html($uri)
- {
-// Kohana::$log->add(Log::INFO, 'Ajax html request begin');
- $arguments = explode('/', $uri);
-
- try {
- $subRequest = Request::Factory($uri);
- $html = $subRequest->execute()->body();
- } catch (Exception $e) {
- //return HTML from exception
-
- $message = $e;
- $ajaxResponse = array(
- 'returnValue' => FALSE,
- 'response' => $this->handleException($e),
- 'arguments'=>$arguments
-
- );
- $this->response->headers('Content-Type', 'application/json');
- $this->response->body(json_encode($ajaxResponse));
- return;
- }
-
-
- $cssResources = array();
- foreach($this->resources['librarycss'] as $css){
- array_push($cssResources, $css);
- }
- foreach($this->resources['css'] as $css){
- array_push($cssResources, $css);
- }
-
- $jsResources = array();
- foreach($this->resources['libraryjs'] as $js){
- array_push($jsResources, $js);
- }
- foreach($this->resources['js'] as $js){
- array_push($jsResources, $js);
- }
-
- $ajaxResponse = array(
- 'response'=>array(
- 'html'=>$html,
- 'js'=>$jsResources,
- 'css'=>$cssResources
- ),
- 'returnValue' => TRUE,
- 'arguments'=>$arguments
- );
- $this->response->headers('Content-Type', 'application/json');
- $this->response->body(json_encode($ajaxResponse));
- }
-
- public function action_compound($uri)
- {
- $arguments = explode('/', $uri);
-
- try {
- $subRequest = Request::Factory($uri);
- $requestResponse = $subRequest->execute();
- } catch (Exception $e) {
- //return HTML from exception
- $message = $e;
- $ajaxResponse = array(
- 'returnValue' => FALSE,
- 'response' => $this->handleException($e),
- 'arguments'=>$arguments
- );
- $this->response->headers('Content-Type', 'application/json');
- $this->response->body(json_encode($ajaxResponse));
- return;
- }
-
-
- $cssResources = array();
- foreach($this->resources['librarycss'] as $css){
- array_push($cssResources, $css);
- }
- foreach($this->resources['css'] as $css){
- array_push($cssResources, $css);
- }
-
- $jsResources = array();
- foreach($this->resources['libraryjs'] as $js){
- array_push($jsResources, $js);
- }
- foreach($this->resources['js'] as $js){
- array_push($jsResources, $js);
- }
-
-
- $compoundResponse = array(
- 'data' => $requestResponse->data(),
- 'html' => $requestResponse->body(),
- 'css' => $cssResources,
- 'js' => $jsResources,
- );
- $ajaxResponse = array(
- 'returnValue' => TRUE,
- 'response'=>$compoundResponse,
- 'arguments'=>$arguments
- );
- $this->response->headers('Content-Type', 'application/json');
- $this->response->body(json_encode($ajaxResponse));
- }
-
-} // End Welcome
+
+} // End Ajax
View
2 classes/controller/associator.php
@@ -1,4 +1,4 @@
-<?
+<?php
Class Controller_Associator extends Lattice_Controller_Associator {
View
177 classes/controller/auth.php
@@ -1,179 +1,8 @@
<?php defined('SYSPATH') or die('No direct script access.');
/**
- * @package LatticeAuth
+ * @package Lattice_auth
* @author Deepwinter
*/
-class Controller_Auth extends Controller_Layout {
+class Controller_Auth extends Lattice_Controller_Auth {
- protected $_actionsThatGetLayout = array(
- 'index',
- 'login',
- 'logout',
- 'noaccess',
- 'forgot',
- );
-
-
- // Use the default Kohana objectType
- public $defaultobjectType = 'auth/objectType';
-
- public $message = '';
-
- public function __construct($request, $response){
- parent::__construct($request, $response);
-
- I18n::lang('en');
- }
-
- public function action_index()
- {
- $this->action_login();
- }
-
- /*
- * Currently not supporting public creation of users
- public function action_create()
- {
- $this->view->title = 'Create User';
-
- $form = new Forge('auth/create');
- $form->input('email')->label(TRUE)->rules('required|length[4,32]|valid_email');
- $form->input('username')->label(TRUE)->rules('required|length[4,32]');
- $form->password('password')->label(TRUE)->rules('required|length[5,40]');
- $form->submit('Create New User');
-
- if ($form->validate())
- {
- // Create new user
- $user = ORM::factory('user');
-
- if ( ! $user->username_exists($form->username->value))
- {
- foreach ($form->as_array() as $key => $val)
- {
- // Set user data
- $user->$key = $val;
- }
-
- if ($user->save() AND $user->add(ORM::factory('role', 'login')))
- {
- Auth::instance()->login($user, $form->password->value);
-
- // Redirect to the login object
- Request::current()->redirect('auth/login');
- }
-
- } else {
- }
- }
-
- $this->view = new View('auth/create');
- $this->view->content = $form->render();
- }
- */
-
- public function action_login($redirect = null)
- {
-
-
- $error = null;
-
- /*
- * Switch to validate library
- $form->input('username')->label(TRUE)->rules('required|length[4,32]');
- $form->password('password')->label(TRUE)->rules('required|length[5,40]');
- */
-
- $formValues = $_POST;
- if (isset($formValues['submit']) )
- {
- // Load the user
- if (Auth::instance()->login($formValues['username'], $formValues['password']))
- {
- // Login successful, redirect
- //somewhere in here we can hang extra values for user roles
- //just override auth.redirect or something
- $authredirect = Kohana::config('auth.redirect');
-
- if($formValues['redirect']){
- Request::current()->redirect(url::site($formValues['redirect'],Request::current()->protocol(),false));
- } else if($redirect = $authredirect){
- Request::current()->redirect(url::site($redirect,Request::current()->protocol(),false));
- } else {
- Request::current()->redirect(url::site('auth/login',Request::current()->protocol(),false));
- }
- return;
- }
- else
- {
- $error = 'Invalid username or password.';
- }
- }
-
- if (isset($_GET["redirect"])){
- $redirect = $_GET["redirect"];
- }
-
- $view = new View('auth/login');
-
- if($redirect == 'resetPasswordSuccess'){
- $view->message = I18n::get('resetPasswordSuccess');
- $redirect = null;
- } else if($error){
- $view->message = $error;
- }
- $view->title = 'User Login';
-
- if(!$redirect){
- if(isset($formValues['redirect'])){
- $redirect = $formValues['redirect'];
- }
- }
- $view->redirect = $redirect;
- $this->response->body($view->render());
-
- }
-
- public function action_logout()
- {
- // Force a complete logout
- Auth::instance()->logout(TRUE);
-
- // Redirect back to the login object
- Request::current()->redirect(url::site('auth/login',Request::current()->protocol(),false));
-
- }
-
- public function action_noaccess($controller = NULL){
- $this->message = 'You do not have access to the requested object';
- $this->login($controller);
- }
-
- public function action_forgot(){
- if(isset($_POST['email'])){
- $user = ORM::Factory('user')->where('email', '=', $_POST['email'])->find();
- if($user->loaded() ){
- $password = Utility_Auth::randomPassword();
- $user->password = $password;
- $user->save();
- $body = I18n::get('forgotPasswordEmailBody');
- $body = str_replace('___Lattice___username___Lattice___', $user->username, $body);
- $body = str_replace('___Lattice___password___Lattice___', $password, $body);
-
- mail($user->email, I18n::get('forgotPasswordEmailSubject'), $body);
- Request::current()->redirect('auth/login/resetPasswordSuccess');
-
- } else {
- $view = new View('auth/forgot');
- $view->message = I18n::get('resetPasswordFailed');
-
- }
- } else {
- $view = new View('auth/forgot');
- }
- $this->response->body($view);
- }
-
-
-
-} // End Auth Controller
+} // End Auth Controller
View
17 classes/controller/authstatus.php
@@ -1,19 +1,8 @@
-<?
+<?php
/*
- * Class: Lattice_Auth_Controller
+ * Class: Controller_Authstatus extends Lattice_Controller_Authstatus
* Reponsible for the 'logged in as' object on the MOP backend objects
*/
-class Controller_AuthStatus extends Controller {
+class Controller_Authstatus extends Lattice_Controller_Authstatus {
- /*
- * Function: createIndexView()
- * Implements abstract function in base assigning the main view
- */
- public function action_index(){
- $view = new View('logged_in_as');
- if(Auth::instance()->get_user()){
- $view->username = Auth::instance()->get_user()->username;
- }
- $this->response->body($view->render());
- }
}
View
317 classes/controller/builder.php
@@ -1,316 +1,5 @@
-<?
-
-class Controller_Builder extends Controller {
-
- private $newObjectIds = array();
-
- public function __construct(){
-
- if(!latticeutil::checkRoleAccess('superuser') && PHP_SAPI != 'cli' ){
- die('Only superuser can access builder tool');
- }
-
- $this->rootNodeObjectType = Kohana::config('cms.graphRootNode');
-
- }
-
- 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 action_initializeSite($xmlFile='data'){
-
- $mtime = microtime();
- $mtime = explode(' ', $mtime);
- $mtime = $mtime[1] + $mtime[0];
- $starttime = $mtime;
-
-
- if(Kohana::config('lattice.live')){
- die('builder/initializeSite is disabled on sites marked live');
- }
-
- //clean out media dir
- $this->destroy('application/media/');
-
- $db = Database::instance();
- $db->query(Database::DELETE, 'delete from objects');
- $db->query(Database::UPDATE, 'alter table objects AUTO_INCREMENT = 1');
- $db->query(Database::DELETE, 'delete from contents');
- $db->query(Database::UPDATE, 'alter table contents AUTO_INCREMENT = 1');
- $db->query(Database::DELETE, 'delete from objecttypes');
- $db->query(Database::UPDATE, 'alter table objecttypes AUTO_INCREMENT = 1');
- $db->query(Database::DELETE, 'delete from objectmaps');
- $db->query(Database::UPDATE, 'alter table objectmaps AUTO_INCREMENT = 1');
- $db->query(Database::DELETE, 'delete from objectrelationships');
- $db->query(Database::UPDATE, 'alter table objectrelationships AUTO_INCREMENT = 1');
- $db->query(Database::DELETE, 'delete from objectelementrelationships');
- $db->query(Database::UPDATE, 'alter table objectelementrelationships AUTO_INCREMENT = 1');
- $db->query(Database::DELETE, 'delete from rosettas');
- $db->query(Database::UPDATE, 'alter table rosettas AUTO_INCREMENT = 1');
- $db->query(Database::DELETE, 'delete from tags');
- $db->query(Database::UPDATE, 'alter table tags AUTO_INCREMENT = 1');
- $db->query(Database::DELETE, 'delete from objects_tags');
- $db->query(Database::UPDATE, 'alter table objects_tags AUTO_INCREMENT = 1');
- $db->query(Database::DELETE, 'delete from tags_tagbuckets');
- $db->query(Database::UPDATE, 'alter table tags_tagbuckets AUTO_INCREMENT = 1');
- flush();
- ob_flush();
-
- //immediately reinitialize the graph
- Graph::configureObjectType($this->rootNodeObjectType, true);
- Graph::addRootNode($this->rootNodeObjectType);
-
- if($xmlFile != 'data'){
- //then we are loading an export
- $xmlFile = 'application/export/'.$xmlFile.'/'.$xmlFile.'.xml';
- }
- echo "\nInserting Data\n";
- $this->insertData($xmlFile, NULL, lattice::config($xmlFile, 'nodes')->item(0) );
-
- latticecms::regenerateImages();
-
- $this->insertRelationships($xmlFile);
-
- //and run frontend
- echo "\n Regenerating Frontend";
- $this->action_frontend();
-
-
- $memoryUseFollowingAction = memory_get_usage(true);
-
- $mtime = microtime();
- $mtime = explode(" ", $mtime);
- $mtime = $mtime[1] + $mtime[0];
- $endtime = $mtime;
- $totaltime = ($endtime - $starttime);
- echo '<!-- initializeSite took ' .$totaltime. ' seconds, and completed with memory usage of '.$memoryUseFollowingAction;
- echo 'done';
-
- }
-
- public function insertRelationships($xmlFile){
-
- $lattices = lattice::config($xmlFile, 'relationships/lattice');
- foreach($lattices as $latticeDOM){
- $lattice = Graph::lattice($latticeDOM->getAttribute('name'));
- $relationships = lattice::config($xmlFile, 'relationship', $latticeDOM);
- foreach($relationships as $relationship){
- $parentSlug = $relationship->getAttribute('parent');
- $childSlug = $relationship->getAttribute('child');
- //echo 'Adding lattice relationship';
- $parent = Graph::object($parentSlug)->addLatticeRelationship($lattice, $childSlug);
- }
- unset($relationships);
- }
- unset($lattices);
- }
-
- public function action_frontend(){
- $frontend = new Builder_Frontend();
- $frontend->index();
-
- }
-
- public function action_addData($xmlFile, $secondaryRootNodeObjectType=null){
-
- if($secondaryRootNodeObjectType && !$parentId = Graph::getRootNode($secondaryRootNodeObjectType)){
- Graph::configureObjectType($secondaryRootNodeObjectType);
- Graph::addRootNode($secondaryRootNodeObjectType);
- $parentObject = Graph::getRootNode($secondaryRootNodeObjectType);
- } else {
- $parentObject = Graph::getRootNode($this->rootNodeObjectType);
- }
-
- $xmlFile = 'application/export/'.$xmlFile.'/'.$xmlFile.'.xml';
-
- $this->insertData($xmlFile, $parentObject->id, lattice::config($xmlFile, 'nodes')->item(0) );
-
- $this->insertRelationships($xmlFile);
-
- latticecms::generateNewImages($this->newObjectIds);
- }
-
-
-
- public function insertData($xmlFile, $parentId = null, $context=null){
- if($parentId == null){
- $parentObject = Graph::getRootNode($this->rootNodeObjectType);
- } else {
- $parentObject = Graph::object($parentId);
- }
-
-
- $items = lattice::config($xmlFile, 'item', $context);
- foreach($items as $item){
-
- if(!$item->getAttribute('objectTypeName')){
- //echo $item->tagName;
- throw new Kohana_Exception("No objecttypename specified for Item " . $item->tagName);
- }
-
-
- $object = Graph::instance();
- $objectType = ORM::Factory('objecttype', $item->getAttribute('objectTypeName'));
-
- $data = array();
- $clustersData = array();
- $fields = lattice::config($xmlFile, 'field', $item );
- foreach($fields as $content){
- $field = $content->getAttribute('name');
-
- switch ($field) {
- case 'title':
- case 'published':
- $data[$field] = $content->nodeValue;
- continue(2);
- case 'slug':
- $data[$field] = $content->nodeValue;
- $data['decoupleSlugTitle'] = 1;
- continue(2);
- }
-
-
- //need to look up field and switch on field type
- $fieldInfo = lattice::config('objects', sprintf('//objectType[@name="%s"]/elements/*[@name="%s"]', $item->getAttribute('objectTypeName'), $content->getAttribute('name')))->item(0);
- if (!$fieldInfo) {
- throw new Kohana_Exception("Bad field in data/objects!\n" . sprintf('//objectType[@name="%s"]/elements/*[@name="%s"]', $item->getAttribute('objectTypeName'), $content->getAttribute('name')));
- }
-
- //if an element is actually an object, prepare it for insert/update
- if (lattice::config('objects', sprintf('//objectType[@name="%s"]', $fieldInfo->tagName))->length > 0) {
- //we have a cluster..
- $clusterData = array();
- foreach (lattice::config($xmlFile, 'field', $content) as $clusterField) {
- $clusterData[$clusterField->getAttribute('name')] = $clusterField->nodeValue;
- }
-
- $clustersData[$field] = $clusterData;
- //have to wait until object is inserted to respect translations
- //echo 'continuing';
- continue;
- }
-
-
- //special setup based on field type
- switch ($fieldInfo->tagName) {
- case 'file':
- case 'image':
- $path_parts = pathinfo($content->nodeValue);
- $savename = Model_Object::makeFileSaveName($path_parts['basename']);
- if (file_exists($content->nodeValue)) {
- copy(str_replace('index.php', '', $_SERVER['SCRIPT_FILENAME']) . $content->nodeValue, Graph::mediapath($savename) . $savename);
- $data[$field] = $savename;
- } else {
- if($content->nodeValue){
- throw new Kohana_Exception( "File does not exist {$content->nodeValue} ");
- }
- }
- break;
- default:
- $data[$field] = $content->nodeValue;
- break;
- }
-
- }
- //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
- $component = false;
- if(isset($data['title']) && $data['title']){
- $preexistingObject = Graph::object()
- ->latticeChildrenFilter($parentObject->id)
- ->join('contents', 'LEFT')->on('objects.id', '=', 'contents.object_id')
- ->where('title', '=', $data['title'])
- ->find();
- if($preexistingObject->loaded()){
- $component = $preexistingObject;
- //echo 'Found prexisting component: '.$preexistingObject->objecttype->objecttypename;
- }
- }
-
- //check for pre-existing object as list container
- //echo sprintf('//objectType[@name="%s"]/elements/list', $parentObject->objecttype->objecttypename);
- foreach(lattice::config('objects', sprintf('//objectType[@name="%s"]/elements/list', $parentObject->objecttype->objecttypename)) as $listContainerType){
- $preexistingObject = Graph::object()
- ->latticeChildrenFilter($parentObject->id)
- ->objectTypeFilter($listContainerType->getAttribute('name'))
- ->find();
- if($preexistingObject->loaded() && $preexistingObject->objecttype->objecttypename == $item->getAttribute('objectTypeName') ){
- //echo 'Found prexisting list container: '.$preexistingObject->objecttype->objecttypename .' '.$item->getAttribute('objectTypeName');
- $component = $preexistingObject;
- }
- }
-
-
- if($component){
- //echo 'Updating Object '.$component->objecttype->objecttypename."\n";
- //print_r($data);
- $component->updateWithArray($data);
- $objectId = $component->id;
- } else {
- //actually add the object
- //echo 'Adding Object '.$item->getAttribute('objectTypeName')."\n";
- //print_r($data);
- $objectId = $parentObject->addObject($item->getAttribute('objectTypeName'), $data);
- $this->newObjectIds[] = $objectId;
- }
-
- //and now update with elementObjects;
- if(count($clustersData)){
- $object = Graph::object($objectId);
- //echo "Updating clusters\n";
- $object->updateWithArray($clustersData);
- }
-
-
- //do recursive if it has children
- if(lattice::config($xmlFile, 'item', $item)->length ){
- $this->insertData($xmlFile, $objectId, $item);
- }
-
- $lists = lattice::config($xmlFile, 'list', $item);
- foreach($lists as $list){
- //find the container
- $container = Graph::object()
- ->latticeChildrenFilter($objectId)
- ->objectTypeFilter($list->getAttribute('name'))
- ->find();
-
- //jump down a level to add object
- $this->insertData($xmlFile, $container->id, $list);
- }
- unset($lists);
-
- }
- unset($items);
-
- }
-
-
- public function action_regenerateImages(){
- try {
- latticecms::regenerateImages();
- } catch(Exception $e){
- print_r($e->getMessage() . $e->getTrace());
- }
- echo 'Done';
- flush();
- ob_flush();
- }
+<?php
+class Controller_Builder extends Lattice_Controller_Builder {
+
}
View
38 classes/controller/cms.php
@@ -1,39 +1,5 @@
-<?
+<?php
-class Controller_CMS extends Lattice_CMS {
-
- public function getRootObject(){
- $rootObjectType = ORM::factory('objectType')->where('objectTypeName', '=', Kohana::config('cms.graphRootNode'))->find();
- $rootObject = Graph::object()->objectTypeFilter($rootObjectType->id)->find();
- return $rootObject;
-
- }
-
-
- public function cms_addObject($parentId, $objectTypeId, $data) {
-
- $newId = Graph::object($parentId)->addObject($objectTypeId, $data);
- return $newId;
-
- }
-
- public function cms_getNodeInfo($id){
-
- //Dial up associated navi and ask for details
- return Navigation::getNodeInfoById($id);
-
- }
-
- public function cms_getNodeHtml($id){
-
- //Dial up associated navi and ask for details
- $item = Navigation::getNodeInfoById($id);
- $nodeView = new View('navigationNode');
- $nodeView->content = $item;
- return $nodeView->render();
-
- }
-
-
+class Controller_CMS extends Lattice_Controller_CMS {
}
View
289 classes/controller/csv.php
@@ -1,290 +1,5 @@
-<?
+<?php
-Class Controller_CSV extends Controller {
-
- private $csvOutput = '';
- private $level = 0;
- private $lineNumber = 0;
-
- public function __construct($request, $response){
- parent::__construct($request, $response);
- if(!latticeutil::checkRoleAccess('superuser') && PHP_SAPI != 'cli' ){
- die('Only superuser can access builder tool');
- }
- }
-
- public function action_index(){
- $view = new View('csv/index');
- $this->response->body($view->render());
- }
-
- public function action_export($exportFileIdentifier='latticeCsvExport'){
- $this->csvOutput = '';
-
- $rootObject = Graph::getLatticeRoot();
-
-
- $this->level = 0;
-
- try {
- $this->csvWalkTree($rootObject);
- } catch (Exception $e){
- echo "Error at line {$this->lineNumber} \n";
- throw $e;
- }
-
- $filename = $exportFileIdentifier .'.csv';
- $filepath = 'application/export/'.$filename;
- $file = fopen($filepath, 'w');
- fwrite($file, $this->csvOutput);
- // exit;
- header("Pragma: public");
- header("Expires: 0");
- header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
- header("Cache-Control: private",false);
- header("Content-Type: csv");
- header("Content-Disposition: attachment; filename=\"".$filename."\";");
- header("Content-Transfer-Encoding: binary");
- header("Content-Length: ".@filesize($filepath));
- set_time_limit(0);
- @readfile($filepath) or throw new Kohana_Exception("File not found.");
- exit;
- }
-
- private function csvWalkTree($parent, $example = false){
- $objects = $parent->getLatticeChildren();
-
- if ($example || ($this->level > 0 && count($objects))) {
- $childrenLine = array_pad(array('Children'), -1 - $this->level, '');
- $this->csvOutput .= latticeutil::arrayToCsv($childrenLine, ',');
- $this->csvOutput .= "\n";
- }
-
- foreach($objects as $object){
-
- $csvView = NULL;
- if($object->objecttype->nodeType != 'container'){
- $csvView = new View_CSV($this->level, $object);
- } else {
- $csvView = new View_CSVContainer($this->level, $object);
- }
- $this->csvOutput .= $csvView->render();
- $this->level++;
- $this->csvWalkTree($object, false); //false turning off example for now
- //big problem with walking descedent objects since they don't exist
-
- if($example){
- //And now append one example object of each addable object
- foreach ($object->objecttype->addableObjects as $addableObjectType) {
- $object = Graph::object()->setObjectType($addableObjectType['objectTypeId']);
-
-
- $csvView = new View_Csv($this->level, $object);
- $this->csvOutput .= $csvView->render();
-
-
- }
- }
- $this->level--;
- }
-
- }
-
- public function action_import(){
- $view = new View('csv/uploadform');
- $this->response->body($view->render());
- }
-
- public function action_importCSVFile($csvFileName=NULL){
- //get the php default Resource Limits
- $max_execution_time = ini_get("max_execution_time");
- $memory_limit = ini_get("memory_limit");
-
-
- $max_execution_time = ini_get("max_execution_time");
- $memory_limit = ini_get("memory_limit");
-
- if($csvFileName == NULL){
- $this->csvFile = fopen($_FILES['upload']['tmp_name'], 'r');
- } else {
- $this->csvFile = fopen($csvFileName, 'r');
- }
- $this->column = 0;
-
- $this->walkCSVObjects(Graph::getLatticeRoot());
-
- fclose($this->csvFile);
-
- try {
- latticecms::regenerateImages();
- } catch(Exception $e){
- print_r($e->getMessage() . $e->getTrace());
- }
-
- echo 'Done';
- }
-
- protected function walkCSVObjects($parent){
- $this->advance();
- while($this->line){
- $objectTypeName = $this->line[$this->column];
- if(!$objectTypeName){
- throw new Kohana_Exception("Expecting objectType at column :column, but none found :line",
- array(
- ':column'=>$this->column,
- ':line'=>$this->lineNumber,
- ));
- }
-
- //check if this object type is valid for the current objects.xml
- $objectConfig = lattice::config('objects', sprintf('//objectType[@name="%s"]', $objectTypeName));
- if(!$objectConfig->item(0)){
- throw new Kohana_Exception("No object type configured in objects.xml for ".$objectTypeName);
- }
-
- //we have an objectType
- $newObjectId = $parent->addObject($objectTypeName);
- $newObject = Graph::object($newObjectId);
- $this->walkCSVElements($newObject);
-
- }
-
- echo 'Done';
- flush();
- ob_flush();
- }
-
- protected function walkCSVElements($object){
- echo "Walking\n";
-
- if($object->objecttype->nodeType != 'container'){
- //get the elements line
- $this->advance();
- //check here for Elements in $this->column +1;
- if(!(isset($this->line[$this->column+1])) || $this->line[$this->column+1] != 'Elements'){
- throw new Kohana_Exception("Didn't find expected Elements line at line ".$this->lineNumber);
- }
- }
-
-
- //iterate through any elements
- $this->advance();
- $data = array();
- while(isset($this->line[$this->column])
- && $this->line[$this->column]==''
- && $this->line[$this->column+1]!=''
- && $this->line[$this->column+1]!='Children'){
- $fieldName = $this->line[$this->column+1];
- //echo "Reading $fieldName \n";
- if(isset($this->line[$this->column+2])){
- $value = $this->line[$this->column+2];
- } else {
- $value = null;
- }
- $field = strtok($fieldName, '_');
- $lang = strtok('_');
- if(!isset($data[$lang])){
- $data[$lang] = array();
- }
- $data[$lang][$field] = $value;
-
- $this->advance();
- }
-
-
-
-
- //and actually add the data to the objects
- foreach($data as $lang=>$langData){
- $objectToUpdate = $object->getTranslatedObject(Graph::language($lang));
- foreach($langData as $field => $value){
-
- if($field=='tags'){
- if($value){
- $tags = explode(',',$value);
- foreach($tags as $tag){
- $objectToUpdate->addTag($tag);
- }
- }
- continue;
- }
-
- $objectToUpdate->$field = $value;
-
- if(in_array($field, array('title', 'slug', 'published', 'dateadded'))){
- continue;
- }
-
- //need to look up field and switch on field type
- $fieldInfo = lattice::config('objects', sprintf('//objectType[@name="%s"]/elements/*[@name="%s"]',$object->objecttype->objecttypename, $field));
- $fieldInfo = $fieldInfo->item(0);
- if (!$fieldInfo) {
- throw new Kohana_Exception("Bad field in data/objects!\n" . sprintf('//objectType[@name="%s"]/elements/*[@name="%s"]', $object->objecttype->objecttypename, $field));
- }
-
-
- //special setup based on field type
- switch ($fieldInfo->tagName) {
- case 'file':
- case 'image':
- $path_parts = pathinfo($value);
- $savename = Model_Object::makeFileSaveName($path_parts['basename']);
- //TODO: Spec and engineer this, import media path needs to be fully workshopped
- //$importMediaPath = Kohana::config('cms.importMediaPath');
- //$imagePath = $_SERVER['DOCUMENT_ROOT']."/".trim($importMediaPath,"/")."/".$value;
- $imagePath = $value;
- if (file_exists($imagePath)) {
- copy($imagePath, Graph::mediapath($savename) . $savename);
- $file = ORM::Factory('file');
- $file->filename = $savename;
- $file->save();
- $objectToUpdate->$field = $file->id;
- } else {
- if($value){
- echo "file does not exist";
- //throw new Kohana_Exception( "File does not exist {$value} ");
- }
- }
- break;
- default:
- break;
- }
-
-
- }
- $objectToUpdate->save();
- }
-
- //Check here for Children in $this->column +1
- if(!isset($this->line[$this->column+1]) || $this->line[$this->column+1] != 'Children'){
- echo "No children found, returning from Walk ";//.implode(',', $this->line)."\n";
- return;
- }
-
- //Iterate through any children
- $this->advance();
- while(isset($this->line[$this->column])
- && $this->line[$this->column]==''
- && $this->line[$this->column+1]!=''){
- //echo "foudn Child\n";
- //echo $this->column;
- $childObjectTypeName = $this->line[$this->column+1];
- $childObjectId = $object->addObject($childObjectTypeName);
- $childObject = Graph::object($childObjectId);
- $this->column++;
- //echo $this->column;
- $this->walkCSVElements($childObject);
- $this->column--;
- }
-
- echo "Returning from Walk\n";
- //at this point this->line contains the next object to add at this depth level
-
- }
-
- protected function advance(){
- $this->lineNumber++;
- $this->line = fgetcsv($this->csvFile);
- }
+Class Controller_CSV extends Lattice_Controller_CSV {
}
View
43 classes/controller/csvimports.php
@@ -1,44 +1,5 @@
-<?
+<?php
-Class CsvImports_Controller extends Controller {
+Class Controller_Csvimports extends Lattice_Controller_Csvimports {
- /*
- * Function: createImportTemplateFilled($view)
- * This function creates a csv import template which has data pre-filled from the table
- */
- public function createImportTemplateFilled($view){
- $data = mop::getViewContent($view);
-
- $outputCSV = fopen('application/media/'.$view.'.csv', 'w');
-
- //print_r($data);
- //safely compute fields
- $columns = array();
- foreach($data['content']['csv'] as $item){
- foreach($item as $field => $value){
- // $label = mop::config('objects',
- $columns[$field] = $field;
- }
- }
- fputcsv($outputCSV, $columns);
-
- // print_r($columns);
-
- //output the file
- foreach($data['content']['csv'] as $item){
- $output = array();
- foreach($columns as $column => $label){
- if(isset($item[$column])){
- $output[] = $item[$column];
- } else {
- $output[] = '';
- }
- }
- // print_r($output);
- fputcsv($outputCSV, $output);
- }
-
- fclose($outputCSV);
-
- }
}
View
342 classes/controller/customreel.php
@@ -1,343 +1,5 @@
-<?
-/* @package usermanagement
- * Class: UserManagement_Controllers
- * Controller for usermangement module within LatticeCMS, allows for settings up users
- * and passwords. Can be configured deal with roles using the managedroles variables.
- */
+<?php
-Class Controller_CustomReel extends Controller_Layout {
-
- protected $_actionsThatGetLayout = array('index');
-
-
-
- /*
- * 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($request, $response){
- parent::__construct($request, $response);
-
- $this->managedRoles = Kohana::config(strtolower($this->controllerName).'.managedRoles');
- if(Kohana::config(strtolower($this->controllerName).'.superuserEdit')
- && latticeutil::checkRoleAccess('superuser')){
- if(is_array($this->managedRoles)){
- $keys = array_keys($this->managedRoles);
- $vals = array_values($this->managedRoles);
- array_unshift($keys,'Superuser');
- array_unshift($vals,'superuser');
- $this->managedRoles = array_combine($keys, $vals);
- }
- }
-
- }
-
- /*
- * Function: createIndexView()
- * Subclassed function to build the top view
- * Parameters: none
- * Returns: nothing, sets up view to render in this->view
- */
- public function action_index(){
- //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 = strtolower($this->controllerName);
-
- $users = ORM::Factory($this->table)->find_all();
- $managedUsers = array();
- foreach($users as $user){
- foreach($this->managedRoles as $role){
- if($user->has('roles', ORM::Factory('role', array('name'=>$role)))){
- $managedUsers[] = $user;
- continue (2);
- }
- }
- }
- $html = '';
- foreach($managedUsers as $user){
- $userItemView = $this->createUserItemView($user);
- $html .= $userItemView->render();
- }
-
-
- $this->view->items = $html;
- $this->response->body($this->view->render());
-
- }
-
- protected function getUserData($user){
- $data['id'] = $user->id;
- $data['username'] = $user->username;
- $data['firstname'] = $user->firstname;
- $data['lastname'] = $user->lastname;
- $data['email'] = $user->email;
-
- if(strstr($data['email'], 'PLACEHOLDER')){
- $data['email'] = '';
- }
-
- if(strlen($user->password)){
- $data['password'] = '******';
- } else {
- $data['password'] = '';
- }
-
- $data['role'] = $this->getActiveManagedRole($user);
- if($user->has('roles', ORM::Factory('role')->where('name','=','superuser')->find()) ){
- $data['superuser'] = true;
- } else {
- $data['superuser'] = false;
- }
-
- return $data;
- }
-
- protected function createUserItemView($user){
- $userItemView = new View($this->viewName.'_item');
- $userItemView->data = $this->getUserData($user);
- $userItemView->managedRoles = $this->managedRoles;
- $userItemView->viewData = $this->getUserViewData();
- return $userItemView;
- }
-
- /*
- * Function getViewData()
- * Get data specific for the item view
- */
- protected function getUserViewData(){
- return array();
- }
-
- private function getActiveManagedRole($user){
- $activeRole = null;
- foreach($this->managedRoles as $label=>$role){
- if($user->has('roles', ORM::Factory('role')->where('name','=',$role)->find()) ){
- $activeRole = $role;
- break;
- }
- }
- return $activeRole;
- }
-
- /*
- * Function: addItem($objectid)
- * Ajax interface to add a new user object to the users table.
- * Parameters:
- * $objectid - unused variable, interface needs to be updated
- * Returns: Rendered html editing object for new user object
- */
- public function action_addObject(){
- $user = $this->createUser();
- $data = $user->as_array();
-
- //set no managedRole
- $data['username'] = null;
- $data['password'] = null;
- $data['email'] = null;
- $data['superuser'] = false;