Esempio n. 1
0
 /**
  * Initializes the options for the object
  *
  * Called from {@link __construct()} as a first step of object instantiation.
  *
  * @param   array   Options
  * @return  array   Options
  */
 protected function _initialize(KConfig $options)
 {
     $name = $this->getName();
     $this->attribs = new KObject();
     $attribs = array('class' => 'toolbar toolbar-form-validate type:\'' . $this->_method . '\'', 'href' => '#');
     if (isset($options->attribs)) {
         $attribs = array_merge($attribs, $options->attribs);
     }
     $this->attribs->set($attribs);
     $options->append(array('parent' => null, 'icon' => 'icon-32-' . $name, 'id' => $name, 'text' => ucfirst($name), 'method' => 'get', 'identifier' => null));
     parent::_initialize($options);
 }
Esempio n. 2
0
 protected function _parseTemplate($xml)
 {
     $template = new KObject();
     foreach ($xml as $name) {
         if ($name->name() == 'form') {
             $template->set($name->name(), $name);
         } else {
             $template->set($name->name(), $name->data());
         }
     }
     return $template;
 }
Esempio n. 3
0
 public function getLink($options = array())
 {
     $option = $this->_options['option'];
     $view = KRequest::get('get.view', 'cmd');
     // modify url
     $url = clone KRequest::url();
     $query = new KObject();
     $query->set($url->getquery(1));
     //$query['view']	= 'settings';
     $query->order = null;
     $query->direction = null;
     $query->limit = null;
     $query->offset = null;
     if (isset($query->tmpl)) {
         JTML::_('behavior.modal');
     }
     $this->modal = true;
     //$query['layout']= 'default';
     $query->set($options);
     $url->setQuery($query->get());
     return $url;
 }
Esempio n. 4
0
 public function render($content = ' ', $title = false, array $module = array(), $attribs = array())
 {
     /*
     		KLoader::load('lib.joomla.application.module.helper');
     		$load =& JModuleHelper::_load();
     		$load[] = (object) array(
     			'id' => 50,
     			'title' => $title,
     			     'module' => 'mod_custom',
     			     'position' => 'above',
     			     'content' => $content,
     			     'showtitle' => 1,
     			     'control' => '',
     			     'params' => '
     			moduleclass_sfx=-slide red
     			cache=0
     			
     			',
     			     'user' => 0,
     			     'name' => 'custom',
     			     //'style' => isset($module['style']) ? $module['style'] : 'rounded',
     			     'style' => 'xhtml'
     		);
     		return null;
     		die('<pre>'.print_r($load, true).'</pre>');
     		//*/
     /*
     	 0 => 
     stdClass::__set_state(array(
        'id' => '50',
        'title' => 'Breadcrumb',
        'module' => 'mod_breadcrumbs',
        'position' => 'breadcrumb',
        'content' => '',
        'showtitle' => '0',
        'control' => '',
        'params' => 'showHome=1
     	homeText=Home
     	showLast=1
     	separator=
     	moduleclass_sfx=
     	cache=0
     	
     	',
        'user' => 0,
        'name' => 'breadcrumbs',
        'style' => NULL,
     )),
     */
     $tmp = $module;
     $module = new KObject();
     $module->params = 'moduleclass_sfx=' . @$tmp['moduleclass_sfx'];
     $module->module = 'mod_' . $this->_identifier->package . '_' . $this->_identifier->name;
     $module->id = KFactory::tmp('lib.koowa.filter.int')->sanitize(uniqid());
     $module->title = (string) $title;
     $module->style = isset($tmp['style']) ? $tmp['style'] : 'rounded';
     $module->position = $this->_identifier->package . '-' . $this->_identifier->name;
     $module->showtitle = (bool) $title;
     $module->name = $this->_identifier->package . '_' . $this->_identifier->name;
     $module->user = 0;
     $module->content = $content;
     $module->set($tmp);
     if (!isset($attribs['name'])) {
         $attribs['name'] = $module->position;
     }
     if (!isset($attribs['style'])) {
         $attribs['style'] = $module->style;
     }
     if (!isset($attribs['first'])) {
         $attribs['first'] = null;
     }
     if (!isset($attribs['last'])) {
         $attribs['last'] = null;
     }
     if (($yoofix = JPATH_THEMES . DS . KFactory::get('lib.joomla.application')->getTemplate() . DS . 'lib' . DS . 'php' . DS . 'template.php') && ($isYoo = file_exists($yoofix))) {
         require_once $yoofix;
     }
     if ($isYoo) {
         $attribs['style'] = 'yoo';
     }
     static $chrome;
     $mainframe = JFactory::getApplication();
     $scope = $mainframe->scope;
     //record the scope
     $mainframe->scope = $module->module;
     //set scope to Component name
     // Get module parameters
     $params = new JParameter($module->params);
     // Get module path
     $module->module = preg_replace('/[^A-Z0-9_\\.-]/i', '', $module->module);
     $path = JPATH_BASE . DS . 'modules' . DS . $module->module . DS . $module->module . '.php';
     // Load the module
     if (!$module->user && file_exists($path) && empty($module->content)) {
         $lang =& JFactory::getLanguage();
         $lang->load($module->module);
         $content = '';
         ob_start();
         require $path;
         $module->content = ob_get_contents() . $content;
         ob_end_clean();
     }
     // Load the module chrome functions
     if (!$chrome) {
         $chrome = array();
     }
     KLoader::load('lib.joomla.application.module.helper');
     $load =& JModuleHelper::_load();
     if (!$this->_modules) {
         $this->_modules_backup = $this->_modules = $load;
     }
     $this->_modules[] = $module;
     $load = $this->_modules;
     require_once JPATH_BASE . DS . 'templates' . DS . 'system' . DS . 'html' . DS . 'modules.php';
     $chromePath = JPATH_BASE . DS . 'templates' . DS . $mainframe->getTemplate() . DS . 'html' . DS . 'modules.php';
     if (!isset($chrome[$chromePath])) {
         if (file_exists($chromePath)) {
             require_once $chromePath;
         }
         $chrome[$chromePath] = true;
     }
     //make sure a style is set
     if (!isset($attribs['style'])) {
         $attribs['style'] = 'rounded';
     }
     //dynamically add outline style
     if (JRequest::getBool('tp')) {
         $attribs['style'] .= ' outline';
     }
     $tpl = KFactory::get('lib.joomla.application')->getTemplate();
     $yoofix = false;
     $warpfive = 'templates/' . $tpl . '/layouts/module.php';
     if (JFile::exists(JPATH_ROOT . '/' . $warpfive)) {
         $tpl_dir = JPATH_ROOT . "/templates/{$tpl}";
         //include warp
         require_once $tpl_dir . '/warp/warp.php';
         $warp = Warp::getInstance();
         $warp->getHelper('path')->register($tpl_dir . '/warp/systems/joomla.1.5/helpers', 'helpers');
         $warp->getHelper('path')->register($tpl_dir . '/warp/systems/joomla.1.5/layouts', 'layouts');
         $warp->getHelper('path')->register($tpl_dir . '/layouts', 'layouts');
         $template = KFactory::tmp($this->getTemplate())->addFilters(array('alias'));
         $template->getFilter('alias')->append(array('$this' => '$warp_helper_template'));
         $data = array('warp_helper_template' => $warp->getHelper("template"), '$warp' => $warp);
         $module->menu = false;
         $yoofix = true;
     }
     foreach (explode(' ', $attribs['style']) as $style) {
         $chromeMethod = 'modChrome_' . $style;
         //Warp 5.5 fix
         if ($yoofix) {
             $module->parameter = new JParameter($module->params);
             $data['module'] = $module;
             $data['params'] = array();
             //@TODO count this
             $count = 1;
             $index = 0;
             $data['params']['count'] = $count;
             $data['params']['order'] = $index + 1;
             $data['params']['first'] = $data['params']['order'] == 1;
             $data['params']['last'] = $data['params']['order'] == $count;
             $data['params']['suffix'] = $module->parameter->get('moduleclass_sfx', '');
             $data['params']['menu'] = false;
             // get class suffix params
             $parts = preg_split('/[\\s]+/', $data['params']['suffix']);
             foreach ($parts as $part) {
                 if (strpos($part, '-') !== false) {
                     $yoostyles = explode('-', $part, 2);
                     $data['params'][$yoostyles[0]] = $yoostyles[1];
                 }
             }
             $module->content = $template->loadPath($warpfive, $data)->render(true);
         } elseif (function_exists($chromeMethod)) {
             $module->style = $attribs['style'];
             ob_start();
             $chromeMethod($module, $params, $attribs);
             $module->content = ob_get_contents();
             ob_end_clean();
         }
     }
     $mainframe->scope = $scope;
     //revert the scope
     return $module->content;
 }
Esempio n. 5
0
 /**
  * Instantiate a contact object
  *
  * @param  KConfig $data The request data
  * 
  * @return KObject
  */
 protected function _instantiateContact($data)
 {
     $data->append(array('contact' => new KConfig()));
     $contact = new KObject();
     $contact->set(array('address' => $data->contact->address, 'city' => $data->contact->city, 'country' => $data->contact->country, 'state' => $data->contact->state, 'zip' => $data->contact->zip));
     $this->contact = $contact;
     return $contact;
 }
Esempio n. 6
0
 /**
  * Set the raw value of a property
  * 
  * @param string $name 
  * @param mixed $value 
  * @return void;
  */
 public function set($name, $value = null)
 {
     $property = $this->getEntityDescription()->getProperty($name);
     if (!$property instanceof AnDomainPropertyAbstract) {
         return parent::set($name, $value);
     }
     //if a value is mixin then get its mixer
     if ($value instanceof KMixinAbstract) {
         $value = $value->getMixer();
     }
     $modify = false;
     $name = $property->getName();
     $context = $this->getRepository()->getCommandContext();
     $context['property'] = $property;
     $context['value'] = $value;
     $context['entity'] = $this;
     if ($this->getRepository()->getCommandChain()->run('before.setdata', $context) === false) {
         return $this;
     }
     $value = $context->value;
     if ($property->isSerializable()) {
         $modify = true;
         if ($property->isRelationship() && $property->isManyToOne() && $value) {
             if (!is($value, 'AnDomainEntityAbstract', 'AnDomainEntityProxy')) {
                 throw new AnDomainExceptionType('Value of ' . $property->getName() . ' must be a AnDomainEntityAbstract');
             }
             //if a relationship is a belongs to then make sure the parent
             //is always saved before child
             //example if $topic->author = new author
             //then save the new author first before saving topic
             //only set the dependency
             if ($value->getEntityState() == AnDomain::STATE_NEW) {
                 //save the child before saving the parent
                 $this->getRepository()->getSpace()->setSaveOrder($value, $this);
             }
         }
         //if value is not null do a composite type checking
         if (!is_null($value)) {
             if ($property->isAttribute() && !$property->isScalar()) {
                 if (!is($value, $property->getType())) {
                     throw new AnDomainEntityException('Value of ' . $property->getName() . ' must be a ' . $property->getType() . '. a ' . get_class($value) . ' is given.');
                 }
             }
         }
     } elseif ($property->isRelationship() && $property->isOnetoOne()) {
         $child = $property->getChildProperty();
         $current = $this->get($property->getName());
         //if there's a current value and it's existence depends on
         //the parent entity then remove the current
         if ($current && $child->isRequired()) {
             $current->delete();
         }
         //if a one-to-one relationship then there must be a child key for the property
         //then must set the inverse
         if ($value) {
             $value->set($child->getName(), $this);
         }
         $this->_data[$property->getName()] = $value;
     } elseif ($property->isRelationship() && ($property->isManyToMany() || $property->isOneToMany())) {
         $current = $this->get($name);
         if ($current instanceof AnDomainDecoratorOnetomany) {
             $values = KConfig::unbox($value);
             //can be an KObjectArray or KObjectSet object
             if ($values instanceof KObject && $values instanceof Iterator) {
                 $current->delete();
                 foreach ($values as $value) {
                     $current->insert($value);
                 }
             }
         }
     }
     //only modify if the current value is differnet than the new value
     $modify = $modify && !is_eql($this->get($name), $value);
     if ($modify) {
         //lets bring them back to their orignal type
         if (!is_null($value) && $property->isAttribute() && $property->isScalar()) {
             settype($value, $property->getType());
         }
         if ($this->getEntityState() != AnDomain::STATE_NEW) {
             //store the original value for future checking
             if (!isset($this->_modified[$name])) {
                 $this->_modified[$name] = array('old' => $this->get($name));
             }
             $this->_modified[$name]['new'] = $value;
             //check if the new value is the same as the old one then remove the
             if (is_eql($this->_modified[$name]['old'], $this->_modified[$name]['new'])) {
                 //if there are no modified then reset the entity
                 unset($this->_modified[$name]);
                 if (count($this->_modified) === 0) {
                     $this->reset();
                 }
             }
         }
         $this->_data[$property->getName()] = $value;
         $this->getRepository()->getSpace()->setEntityState($this, AnDomain::STATE_MODIFIED);
         //only track modifications for the updated entities
         if ($this->getEntityState() !== AnDomain::STATE_MODIFIED) {
             $this->_modified = array();
         }
     }
     return $this;
 }
Esempio n. 7
0
 protected function _createButton($url, $name, $button)
 {
     $html = array();
     $var = KInflector::underscore($button);
     $href = new KObject();
     $href->set(array_merge($url->get(), array('view' => $var)));
     $attr = current((array) $button->attributes());
     if ($attr['view'] == KRequest::get('get.view', 'cmd', 'dashboard')) {
         return false;
     }
     $img = isset($attr['img']) ? $attr['img'] : null;
     $attr['img'] = null;
     if (!empty($attr)) {
         $href->set($attr);
     }
     $html[] = '<div><div class="dashboard-button">';
     $html[] = '<a href="' . JRoute::_('index.php?' . http_build_query($href->get())) . '"><img src="' . KFactory::get('admin::com.ninja.helper.default')->img('/48/' . JFile::stripExt(basename($img)) . '.png') . '" alt="' . $button . '"/><span>' . JText::_($button) . '</span></a>';
     $html[] = '</div></div>';
     return implode($html);
 }
Esempio n. 8
0
 public function sortables($option = array())
 {
     $this->sortables = true;
     $document = JFactory::getDocument();
     KFactory::get('admin::com.ninja.helper.default')->js('/sortables.js');
     KFactory::get('admin::com.ninja.helper.default')->css('/sortables.css');
     $options = new KObject();
     $options->form = KFactory::get('admin::com.ninja.helper.default')->formid();
     $options->list = 'tbody.sortable';
     $options->handles = 'td.handle';
     $options->set((array) $option);
     $script = 'window.addEvent(\'domready\', function(){ new NSortables(' . json_encode($options) . '); });';
     $document->addScriptDeclaration($script);
 }
Esempio n. 9
0
 public function usergroup($value = null, $name = 'usergroup', $options = array(), $control_name = 'f')
 {
     if (JVersion::isCompatible('1.6.0')) {
         return JHtml::_('access.usergroup', $name, $value[$name], 'onchange="this.form.submit()"');
     }
     $node = new KObject();
     $node->size = null;
     $node->class = null;
     $node->multiple = null;
     $node->set($options);
     // modify url
     $url = clone KRequest::url();
     $query = $url->getquery(1);
     $acl =& JFactory::getACL();
     $acltree = $acl->get_group_children_tree(null, 'USERS', false);
     $query['usergroup'] = 0;
     $reset = (string) $url->setQuery($query);
     $gtree[] = JHTML::_('select.option', '', 'by usergroup');
     foreach ($acltree as $i => $tree) {
         $tree->text = str_replace(array('&nbsp;', '.', '-'), '', $tree->text);
         $query['usergroup'] = $tree->value;
         if (!in_array($tree->value, array(29, 30))) {
             $gtree[] = $tree;
         } else {
             $gtree[] = JHTML::_('select.optgroup', $tree->text);
         }
     }
     $ctrl = $name;
     $attribs = ' onchange="this.form.submit()" ';
     if ($v = $node->size) {
         $attribs .= 'size="' . $v . '"';
     }
     if ($v = $node->class) {
         $attribs .= 'class="' . $v . '"';
     } else {
         $attribs .= 'class="inputbox autoredirect"';
     }
     if ($m = $node->multiple) {
         $attribs .= 'multiple="multiple"';
         $ctrl .= '[]';
     }
     return JHTML::_('select.genericlist', $gtree, $ctrl, $attribs, 'value', 'text', @$value['usergroup'], $name);
 }