コード例 #1
0
ファイル: Model.php プロジェクト: nabble/ajde
 public static function extendController(Ajde_Controller $controller, $method, $arguments)
 {
     // Register getModel($name) function on Ajde_Controller
     if ($method === 'getModel') {
         if (!isset($arguments[0])) {
             $arguments[0] = $controller->getModule();
         }
         return self::getModel($arguments[0]);
     }
     // TODO: if last triggered in event cueue, throw exception
     // throw new Ajde_Exception("Call to undefined method ".get_class($controller)."::$method()", 90006);
     // Now, we give other callbacks in event cueue chance to return
 }
コード例 #2
0
ファイル: View.php プロジェクト: nabble/ajde
 /**
  * @param Ajde_Controller $controller
  *
  * @return Ajde_View
  */
 public static function fromController(Ajde_Controller $controller)
 {
     $base = MODULE_DIR . $controller->getModule() . '/';
     $action = $controller->getRoute()->getController() ? $controller->getRoute()->getController() . '/' . $controller->getAction() : $controller->getAction();
     $format = $controller->hasFormat() ? $controller->getFormat() : 'html';
     return new self($base, $action, $format);
 }
コード例 #3
0
ファイル: Image.php プロジェクト: nabble/updatemybrowser-v1
 public function process()
 {
     switch ($this->_attributeParse()) {
         case 'base64':
             $image = new Ajde_Resource_Image($this->attributes['filename']);
             $image->setWidth($this->attributes['width']);
             $image->setHeight($this->attributes['height']);
             $image->setCrop($this->attributes['crop']);
             $controller = Ajde_Controller::fromRoute(new Ajde_Core_Route('_core/component:imageBase64'));
             $controller->setImage($image);
             $controller->setWidth(issetor($this->attributes['width'], null));
             $controller->setHeight(issetor($this->attributes['height'], null));
             $controller->setExtraClass(issetor($this->attributes['class'], ''));
             return $controller->invoke();
             break;
         case 'html':
             $image = new Ajde_Resource_Image($this->attributes['filename']);
             $image->setWidth($this->attributes['width']);
             $image->setHeight($this->attributes['height']);
             $image->setCrop($this->attributes['crop']);
             $controller = Ajde_Controller::fromRoute(new Ajde_Core_Route('_core/component:image'));
             $controller->setImage($image);
             $controller->setExtraClass(issetor($this->attributes['class'], ''));
             return $controller->invoke();
             break;
         case 'image':
             return false;
             break;
     }
     // TODO:
     throw new Ajde_Component_Exception('Missing required attributes for component call');
 }
コード例 #4
0
ファイル: Crud.php プロジェクト: nabble/ajde
 public function process()
 {
     switch ($this->_attributeParse()) {
         case 'list':
             $options = issetor($this->attributes['options'], []);
             $crud = new Ajde_Crud($this->attributes['model'], $options);
             $crud->setAction('list');
             return $crud;
             break;
         case 'edit':
             $options = issetor($this->attributes['options'], []);
             $id = issetor($this->attributes['id'], null);
             $crud = new Ajde_Crud($this->attributes['model'], $options);
             $crud->setId($id);
             $crud->setAction('edit/layout');
             return $crud;
             break;
         case 'mainfilter':
             $controller = Ajde_Controller::fromRoute(new Ajde_Core_Route('_core/crud:mainfilter'));
             $controller->setCrudInstance($this->attributes['crud']);
             $controller->setRefresh(issetor($this->attributes['refresh'], false));
             return $controller->invoke();
     }
     // TODO:
     throw new Ajde_Component_Exception();
 }
コード例 #5
0
ファイル: Include.php プロジェクト: nabble/updatemybrowser-v1
 public function process()
 {
     if (!array_key_exists('route', $this->attributes)) {
         // TODO:
         throw new Ajde_Component_Exception();
     }
     return Ajde_Controller::fromRoute(new Ajde_Core_Route($this->attributes['route']))->invoke();
 }
コード例 #6
0
 public function run()
 {
     // For debugger
     $this->addTimer('<i>Application</i>');
     // Create fresh response
     $timer = $this->addTimer('Create response');
     $response = new Ajde_Http_Response();
     $this->setResponse($response);
     $this->endTimer($timer);
     // Bootstrap init
     $timer = $this->addTimer('Run bootstrap cue');
     $bootstrap = new Ajde_Core_Bootstrap();
     $bootstrap->run();
     $this->endTimer($timer);
     // Get request
     $timer = $this->addTimer('Read in global request');
     $request = Ajde_Http_Request::fromGlobal();
     $this->setRequest($request);
     $this->endTimer($timer);
     // Get route
     $timer = $this->addTimer('Initialize route');
     $route = $request->initRoute();
     $this->setRoute($route);
     $this->endTimer($timer);
     // Load document
     $timer = $this->addTimer('Create document');
     $document = Ajde_Document::fromRoute($route);
     $this->setDocument($document);
     $this->endTimer($timer);
     // Load controller
     $timer = $this->addTimer('Load controller');
     $controller = Ajde_Controller::fromRoute($route);
     $this->setController($controller);
     $this->endTimer($timer);
     // Invoke controller action
     $timer = $this->addTimer('Invoke controller');
     $actionResult = $controller->invoke();
     $document->setBody($actionResult);
     $this->endTimer($timer);
     // Get document contents
     $timer = $this->addTimer('Render document');
     $contents = $document->render();
     $this->endTimer($timer);
     // Let the cache handle the contents and have it saved to the response
     $timer = $this->addTimer('Save to response');
     $cache = Ajde_Cache::getInstance();
     $cache->setContents($contents);
     $cache->saveResponse();
     $this->endTimer($timer);
     // Output the buffer
     $response->send();
 }
コード例 #7
0
ファイル: Image.php プロジェクト: nabble/ajde
 public static function getImageTag($filename, $width = null, $height = null, $crop = true, $class = '', $lazy = false, $absoluteUrl = false)
 {
     $image = new Ajde_Resource_Image($filename);
     $image->setWidth($width);
     $image->setHeight($height);
     $image->setCrop($crop);
     $controller = Ajde_Controller::fromRoute(new Ajde_Core_Route('_core/component:image'));
     $controller->setImage($image);
     $controller->setExtraClass($class);
     $controller->setLazy($lazy);
     $controller->setAbsoluteUrl($absoluteUrl);
     return $controller->invoke();
 }
コード例 #8
0
ファイル: Qrcode.php プロジェクト: nabble/ajde
 public function process()
 {
     switch ($this->_attributeParse()) {
         case 'html':
             $qr = new Ajde_Resource_Qrcode($this->attributes['text']);
             $controller = Ajde_Controller::fromRoute(new Ajde_Core_Route('_core/component:qrcode'));
             $controller->setQrcode($qr);
             return $controller->invoke();
             break;
     }
     // TODO:
     throw new Ajde_Component_Exception('Missing required attributes for component call');
 }
コード例 #9
0
ファイル: MediaModel.php プロジェクト: nabble/ajde
 public function getTag($width = null, $height = null, $crop = null, $class = null, $attributes = [], $lazy = false)
 {
     $path = $this->uploadDirectory . $this->thumbnail;
     $image = new Ajde_Resource_Image($path);
     $image->setWidth($width);
     $image->setHeight($height);
     $image->setCrop($crop);
     $controller = Ajde_Controller::fromRoute(new Ajde_Core_Route('_core/component:image'));
     $controller->setImage($image);
     $controller->setExtraClass($class);
     $controller->setAttributes($attributes);
     $controller->setLazy($lazy);
     return $controller->invoke();
 }
コード例 #10
0
ファイル: Revision.php プロジェクト: nabble/ajde
 public function getRevisionsHtml($crud = null)
 {
     if (!$this->getPK()) {
         return;
     }
     $revisions = new RevisionCollection();
     $revisions->addFilter(new Ajde_Filter_Where('model', Ajde_Filter::FILTER_EQUALS, $this->getModelName()));
     $revisions->addFilter(new Ajde_Filter_Where('foreignkey', Ajde_Filter::FILTER_EQUALS, $this->getPK()));
     $revisions->orderBy('time', 'DESC');
     $revisions->limit(self::DEFAULT_LIMIT);
     $controller = Ajde_Controller::fromRoute(new Ajde_Core_Route('_core/crud:revisions'));
     $controller->setRevisions($revisions);
     $controller->setModel($this);
     $controller->setCrudInstance($crud);
     return $controller->invoke();
 }
コード例 #11
0
ファイル: Form.php プロジェクト: nabble/ajde
 public function process()
 {
     switch ($this->_attributeParse()) {
         case 'form':
             $controller = Ajde_Controller::fromRoute(new Ajde_Core_Route('_core/component:form'));
             $controller->setFormAction($this->attributes['route']);
             $controller->setFormId(issetor($this->attributes['id'], spl_object_hash($this)));
             $controller->setExtraClass(issetor($this->attributes['class'], ''));
             $controller->setInnerXml($this->innerXml);
             return $controller->invoke();
             break;
         case 'ajax':
             $controller = Ajde_Controller::fromRoute(new Ajde_Core_Route('_core/component:formAjax'));
             $formAction = new Ajde_Core_Route($this->attributes['route']);
             $formAction->setFormat(issetor($this->attributes['format'], 'json'));
             $controller->setFormAction($formAction->__toString());
             $controller->setFormFormat(issetor($this->attributes['format'], 'json'));
             $controller->setFormId(issetor($this->attributes['id'], spl_object_hash($this)));
             $controller->setExtraClass(issetor($this->attributes['class'], ''));
             $controller->setInnerXml($this->innerXml);
             return $controller->invoke();
             break;
         case 'upload':
             $controller = Ajde_Controller::fromRoute(new Ajde_Core_Route('_core/component:formUpload'));
             if (!isset($this->attributes['options']) || !isset($this->attributes['options']['saveDir']) || !isset($this->attributes['options']['extensions'])) {
                 // TODO:
                 throw new Ajde_Component_Exception('Options saveDir and extensions must be set for AC.Form.Upload');
             }
             $controller->setName($this->attributes['name']);
             $controller->setOptions($this->attributes['options']);
             $controller->setInputId(issetor($this->attributes['id'], spl_object_hash($this)));
             $controller->setExtraClass(issetor($this->attributes['class'], ''));
             return $controller->invoke();
             break;
         case 'embed':
             $controller = Ajde_Controller::fromRoute(new Ajde_Core_Route('form/view.html'));
             $controller->setId($this->attributes['id']);
             return $controller->invoke();
             break;
     }
     // TODO:
     throw new Ajde_Component_Exception();
 }
コード例 #12
0
 public static function dieOnRoute($route)
 {
     ob_get_clean();
     // We start a mini app here to display the route
     // Copied from Ajde_Application
     $route = new Ajde_Core_Route($route);
     $document = Ajde_Document::fromRoute($route);
     // replace document in Ajde_Application
     Ajde::app()->setDocument($document);
     $controller = Ajde_Controller::fromRoute($route);
     $actionResult = $controller->invoke();
     $document->setBody($actionResult);
     if (!$document->hasLayout()) {
         $layout = new Ajde_Layout(Config::get("layout"));
         $document->setLayout($layout);
     }
     echo $document->render();
     die;
 }
コード例 #13
0
ファイル: Include.php プロジェクト: nabble/ajde
 public function process()
 {
     if (!array_key_exists('route', $this->attributes)) {
         // TODO:
         throw new Ajde_Component_Exception();
     }
     $route = $this->attributes['route'];
     if (!$route instanceof Ajde_Core_Route) {
         $route = new Ajde_Core_Route($route);
     }
     $controller = Ajde_Controller::fromRoute($route);
     if (array_key_exists('vars', $this->attributes) && is_array($this->attributes['vars']) && !empty($this->attributes['vars'])) {
         try {
             $view = $controller->getView();
             foreach ($this->attributes['vars'] as $key => $var) {
                 $view->assign($key, $var);
             }
         } catch (Exception $e) {
         }
     }
     return $controller->invoke();
 }
コード例 #14
0
 public static function postProcess(Ajde_Layout $layout)
 {
     $debugger = Ajde_Controller::fromRoute(new Ajde_Core_Route('_core/debugger:view.html'))->invoke();
     $layout->setContents($layout->getContents() . $debugger);
 }
コード例 #15
0
ファイル: NodeModel.php プロジェクト: nabble/ajde
 public function displayPanel()
 {
     $nodetype = (string) $this->get('nodetype');
     $controller = Ajde_Controller::fromRoute(new Ajde_Core_Route('admin/node:panel'));
     $controller->setItem($this);
     return $controller->invoke();
 }
コード例 #16
0
ファイル: Crud.php プロジェクト: nabble/ajde
 /**
  * @throws Ajde_Exception
  *
  * @return mixed
  */
 public function output()
 {
     $controller = Ajde_Controller::fromRoute(new Ajde_Core_Route('_core/crud:' . $this->getOperation()));
     $controller->setCrudInstance($this);
     return $controller->invoke();
 }
コード例 #17
0
ファイル: ApiController.php プロジェクト: nabble/ajde
 public function v1()
 {
     $id = $this->getId();
     $route = new Ajde_Core_Route('api/v1:' . $id . '.json');
     return Ajde_Controller::fromRoute($route)->invoke();
 }
コード例 #18
0
ファイル: LogModel.php プロジェクト: nabble/ajde
 public function displayPanel()
 {
     $controller = Ajde_Controller::fromRoute(new Ajde_Core_Route('admin/system:logpanel'));
     $controller->setItem($this);
     return $controller->invoke();
 }