예제 #1
0
 public function __construct(KConfig $config)
 {
     parent::__construct($config);
     if ($config->fields) {
         $this->setFields(KConfig::unbox($config->fields));
     }
 }
예제 #2
0
 /**
  * Constructor
  *
  * @param   object  An optional KConfig object with configuration options.
  */
 public function __construct(KConfig $config = null)
 {
     //If no config is passed create it
     if (!isset($config)) {
         $config = new KConfig();
     }
     parent::__construct($config);
     // Set the table indentifier
     if (isset($config->identity_column)) {
         $this->_identity_column = $config->identity_column;
     }
     // Reset the row
     $this->reset();
     // Set the new state of the row
     $this->_new = $config->new;
     // Set the row data
     if (isset($config->data)) {
         $this->setData((array) KConfig::unbox($config->data), $this->_new);
     }
     //Set the status
     if (isset($config->status)) {
         $this->setStatus($config->status);
     }
     //Set the status message
     if (!empty($config->status_message)) {
         $this->setStatusMessage($config->status_message);
     }
 }
예제 #3
0
 /**
  * Extracts mention usernames from the entity body and updates the entity.
  *
  * @param KCommandContext $context
  *
  * @return bool
  */
 public function updateMentionsFromBody(KCommandContext $context)
 {
     $entity = $this->getItem();
     $body_mentions = $this->extractMentions($entity->body);
     $body_mentions = array_map('strtolower', $body_mentions);
     $entity_mentions = KConfig::unbox($entity->mentions->username);
     if (is_array($entity_mentions)) {
         $entity_mentions = array_map('strtolower', $entity_mentions);
     }
     //update removed mentions
     if (is_array($body_mentions)) {
         foreach ($entity_mentions as $mention) {
             if (!in_array($mention, $body_mentions)) {
                 $entity->removeMention($mention);
             }
         }
     }
     //remove the body mentions that already exists in the entity mentions
     if (is_array($entity_mentions)) {
         foreach ($body_mentions as $index => $mention) {
             if (in_array($mention, $entity_mentions)) {
                 unset($body_mentions[$index]);
             }
         }
     }
     //what's left are new mentions. Add them to the entity.
     foreach ($body_mentions as $mention) {
         $entity->addMention(trim($mention));
     }
     //keep the list of new mentions so you can notify them later.
     $this->_newly_mentioned = $body_mentions;
 }
    public function javascript($config = array())
    {
        $config = new KConfig($config);
        $config->append(array('keys' => array('Bytes', 'KB', 'MB', 'GB', 'TB', 'PB', 'An error occurred during request', 'You selected following folders and files to be deleted. Are you sure?', 'All Files', 'An error occurred with status code: ', 'An error occurred: ', 'Unknown error', 'Uploaded successfully!', 'Select files from your computer', 'Choose File')));
        $keys = KConfig::unbox($config->keys);
        $map = array();
        foreach ($keys as $key) {
            $map[$key] = $this->translate($key);
        }
        ob_start();
        ?>
        <script>
        if (typeof Files === 'undefined') {
            Files = {};
        }
        (function() {
            var keys = <?php 
        echo json_encode($map);
        ?>
;
            Files._ = function(key) {
                if (typeof keys[key] !== 'undefined') {
                    return keys[key];
                }

                return key;
            };
        })();
        </script>
        <?php 
        $html = ob_get_clean();
        return $html;
    }
예제 #5
0
 /**
  * Constructor
  *
  * @param 	object 	An optional KConfig object with configuration options.
  */
 public function __construct(KConfig $config)
 {
     parent::__construct($config);
     // Set the view identifier
     $this->_menubar = $config->menubar;
     $this->_render = KConfig::unbox($config->render);
 }
예제 #6
0
 public function __construct(KConfig $config = null)
 {
     parent::__construct($config);
     if (isset($config->adapters)) {
         $this->_adapters = KConfig::unbox($config->adapters);
     }
 }
예제 #7
0
 /**
  * Browse Action.
  *
  * @param KCommandContext $context Context parameter
  *
  * @return AnDomainEntitysetDefault
  */
 protected function _actionBrowse(KCommandContext $context)
 {
     $context->append(array('query' => $this->getRepository()->getQuery()));
     $query = $context->query;
     if ($this->q) {
         $query->keyword($this->getService('anahita:filter.term')->sanitize($this->q));
     }
     if ($this->ids) {
         $ids = KConfig::unbox($this->ids);
         $query->id($ids);
     } else {
         $query->limit($this->limit, $this->start);
     }
     $entities = $query->toEntitySet();
     if ($this->isOwnable() && $this->actor) {
         $this->_state->append(array('filter' => 'following'));
         if ($this->filter == 'administering' && $this->getRepository()->hasBehavior('administrable')) {
             $entities->where('administrators.id', 'IN', array($this->actor->id));
         } elseif ($this->actor->isFollowable()) {
             $entities->where('followers.id', 'IN', array($this->actor->id));
         }
     }
     $entities->order('created_on', 'desc');
     return $this->setList($entities)->getList();
 }
예제 #8
0
파일: person.php 프로젝트: e-tyatte/anahita
 /**
  * Browse Action.
  *
  * @param KCommandContext $context Context parameter
  *
  * @return ComPeopleDomainEntityPerson
  */
 protected function _actionBrowse(KCommandContext $context)
 {
     if (!$context->query) {
         $context->query = $this->getRepository()->getQuery();
     }
     $query = $context->query;
     if ($this->filter) {
         if ($this->filter['usertype'] && in_array($this->filter['usertype'], $this->_allowed_user_types)) {
             $query->filterUsertype($this->getService('koowa:filter.cmd')->sanitize($this->filter['usertype']));
         }
         if ($this->filter['disabled']) {
             $query->filterDisabledAccounts(true);
         }
     }
     if ($this->getService('koowa:filter.email')->validate($this->q)) {
         $query->filterEmail($this->q);
     }
     if ($this->getService('com://site/people.filter.username')->validate($this->q)) {
         $query->filterUsername($this->q);
     }
     if ($this->q) {
         $query->keyword = $this->getService('anahita:filter.term')->sanitize($this->q);
     }
     if ($this->ids) {
         $ids = KConfig::unbox($this->ids);
         $query->id($ids);
     } else {
         $query->limit($this->limit, $this->start);
     }
     $entities = $this->getState()->setList($query->toEntityset())->getList();
     //print str_replace('#_', 'jos', $entities->getQuery());
     return $entities;
 }
예제 #9
0
파일: story.php 프로젝트: stonyyi/anahita
 /**
  * Creates a new story.
  * 
  * @param array $data The story data
  * 
  * @return ComStoriesDomainEntityStory
  */
 public function create($data)
 {
     $data = new KConfig($data);
     $data->append(array('owner' => $data->target ? $data->target : $data->subject));
     $data = KConfig::unbox($data);
     return $this->getEntity(array('data' => $data));
 }
예제 #10
0
 /**
  * Sets the assignment
  */
 protected function _actionAssign(KCommandContext $context)
 {
     if ($item = $this->getService('com://admin/components.domain.set.assignablecomponent')->find(array('id' => $this->id))) {
         $item->setAssignmentForIdentifier(KConfig::unbox($context->data->identifiers));
         $item->save();
     }
 }
예제 #11
0
파일: event.php 프로젝트: stonyyi/anahita
 /**
  * Object constructor
  *
  * @param   object  An optional KConfig object with configuration options
  */
 public function __construct(KConfig $config)
 {
     parent::__construct($config);
     if (is_null($config->event_dispatcher)) {
         throw new KMixinException('event_dispatcher [KEventDispatcher] option is required');
     }
     //Set the event dispatcher
     $this->_event_dispatcher = $config->event_dispatcher;
     //Add the event listeners
     if (!empty($config->event_listeners)) {
         foreach ($config->event_listeners as $event => $listener) {
             $this->addEventListener($event, $listener);
         }
     }
     //Add the event handlers
     if (!empty($config->event_subscribers)) {
         $subscribers = (array) KConfig::unbox($config->event_subscribers);
         foreach ($subscribers as $key => $value) {
             if (is_numeric($key)) {
                 $this->addEventSubscriber($value);
             } else {
                 $this->addEventSubscriber($key, $value);
             }
         }
     }
 }
예제 #12
0
 /**
  * Constructor.
  *
  * @param KConfig $config An optional KConfig object with configuration options.
  *
  * @return void
  */
 public function __construct(KConfig $config)
 {
     parent::__construct($config);
     $paths = array_reverse(KConfig::unbox($config->asset_paths));
     foreach ($paths as $path) {
         $this->addPath($path);
     }
 }
예제 #13
0
 /**
  * Restores a state for an action
  * 
  * @param  string $action
  * @return void
  */
 public function persistState($action)
 {
     $state = $this->getRequest();
     // Built the session identifier based on the action
     $identifier = $this->_mixer->getIdentifier() . '.' . $action;
     //Set the state in the session
     KRequest::set('session.' . $identifier, KConfig::unbox($state));
 }
예제 #14
0
 /**
  * Constructor.
  *
  * @param   object  An optional KConfig object with configuration options
  */
 public function __construct(KConfig $config = null)
 {
     parent::__construct($config);
     $this->_title = $config->title;
     $this->_class = $config->class;
     $this->_styles = KConfig::unbox($config->styles);
     $this->_attribs = KConfig::unbox($config->attribs);
 }
예제 #15
0
 /**
  * Set a privacy for a privatable entity 
  * 
  * @param KCommandContext $context Context parameter
  * 
  * @return void
  */
 protected function _actionSetprivacy($context)
 {
     $data = $context->data;
     $names = KConfig::unbox($data->privacy_name);
     settype($names, 'array');
     foreach ($names as $name) {
         $this->getItem()->setPermission($name, $data->{$name});
     }
 }
예제 #16
0
파일: ui.php 프로젝트: LuccaCaldas/anahita
 /**
  * Initializes the options for the object.
  *
  * Called from {@link __construct()} as a first step of object instantiation.
  *
  * @param 	object 	An optional KConfig object with configuration options.
  */
 protected function _initialize(KConfig $config)
 {
     $config->append(array('paths' => array(dirname(__FILE__) . '/ui')));
     parent::_initialize($config);
     $paths = KConfig::unbox($config->paths);
     array_unshift($paths, JPATH_THEMES . '/' . JFactory::getApplication()->getTemplate() . '/html/com_locations/ui');
     $config->paths = $paths;
     $this->_service = get_config_value('locations.service', 'google');
 }
예제 #17
0
 /**
  * Process an array of notifications
  * 
  * @param KCommandContext $context
  * 
  * @return void
  */
 protected function _actionProcess(KCommandContext $context)
 {
     $notifications = $this->getService('repos://site/notifications.notification')->getQuery(true)->status(ComNotificationsDomainEntityNotification::STATUS_NOT_SENT);
     if ($this->id) {
         $ids = (array) KConfig::unbox($this->id);
         $notifications->id($ids);
     }
     $this->sendNotifications($notifications->fetchSet());
 }
예제 #18
0
파일: array.php 프로젝트: stonyyi/anahita
 /**
  * Constructor
  *
  * @param KConfig|null $config  An optional KConfig object with configuration options
  * @return \KObjectArray
  */
 public function __construct(KConfig $config = null)
 {
     //If no config is passed create it
     if (!isset($config)) {
         $config = new KConfig();
     }
     parent::__construct($config);
     $this->_data = KConfig::unbox($config->data);
 }
예제 #19
0
파일: custom.php 프로젝트: stonyyi/anahita
 /**
  * Render a custom element.
  *
  * @param string     $name         The name of the element
  * @param string     $value        The vlaue of the element
  * @param xmlElement $node         The node xml element
  * @param string     $control_name The control name
  * 
  * @see   JElement
  * 
  * @return string
  */
 public function fetchElement($name, $value, &$node, $control_name)
 {
     $data = pick(KConfig::unbox($this->_parent->template_data), array());
     $data['name'] = $name;
     $data['value'] = $value;
     $data['node'] = $node;
     $data['control_name'] = $control_name;
     return (string) $this->_template->loadString($node->data(), $data);
 }
예제 #20
0
 public function __construct(KConfig $config)
 {
     parent::__construct($config);
     $this->setThumbnailSize(KConfig::unbox($config->thumbnail_size));
     if (!self::$_library_loaded) {
         @ini_set('memory_limit', '256M');
         //Load the library
         $this->getService('koowa:loader')->loadIdentifier('com://admin/files.helper.phpthumb.phpthumb');
         self::$_library_loaded = true;
     }
 }
예제 #21
0
 /**
  * Initializes the default configuration for the object
  *
  * Called from {@link __construct()} as a first step of object instantiation.
  *
  * @param KConfig $config An optional KConfig object with configuration options.
  *
  * @return void
  */
 protected function _initialize(KConfig $config)
 {
     $config->append(array('tag_list' => array('p', 'strike', 'u', 'pre', 'address', 'img', 'blockquote', 'b', 'i', 'ul', 'ol', 'li', 'h1', 'h2', 'h3', 'h4', 'h5'), 'tag_method' => 0));
     parent::_initialize($config);
     if ($config->tag_list) {
         $config['tag_list'] = KConfig::unbox($config->tag_list);
     }
     if ($config->tag_method) {
         $config['tag_method'] = KConfig::unbox($config->tag_method);
     }
 }
예제 #22
0
 /**
  * Summerize a story query.
  *
  * @param AnDomainQuery $query  Query object
  * @param array         $config Summerization configuration
  * 
  * @return AnDomainEntityset
  */
 protected function _buildAggregateQuery($query, $config)
 {
     $cases = array();
     $config = KConfig::unbox($config);
     $config[] = array('WHEN @col(name) LIKE "avatar_edit"  THEN IF(@col(subject.id) = @col(target.id), "", @col(id))', 'WHEN @col(name) LIKE "actor_follow" THEN @col(subject.id)');
     foreach ($config as $component => $keys) {
         foreach ($keys as $name => $key) {
             if (!is_numeric($name)) {
                 $names = explode(',', $name);
                 $keys = explode(',', $key);
                 foreach ($keys as $i => $key) {
                     $keys[$i] = '@col(' . $key . '.id)';
                 }
                 foreach ($names as $name) {
                     $cases[] = 'WHEN CONCAT(@col(name),@col(component)) LIKE \'' . $name . $component . '\' THEN CONCAT(' . implode(',', $keys) . ')';
                 }
             } else {
                 $cases[] = $key;
             }
         }
     }
     $cases = array_unique($cases);
     $keys = array();
     //always group by date, name and component
     $date = '@col(name),@col(component),DATE(@col(creationTime))';
     $keys[] = $date;
     if (!empty($cases)) {
         $case = 'CASE TRUE ';
         $case .= implode(' ', $cases) . ' ';
         $case .= 'ELSE CONCAT(@col(target.id),@col(subject.id),@col(object.id)) ';
         $case .= 'END';
         $keys[] = $case;
     } else {
         $keys[] = '@col(target.id),@col(subject.id),@col(object.id)';
     }
     $keys = implode(',', $keys);
     $comment_if = "IF(@col(comment.id) IS NOT NULL AND @col(object.id) IS NOT NULL , CONCAT_WS(',',{$date}, @col(object.id)), CONCAT_WS(',',{$keys}))";
     //don't group if a story has a body or it has directly been commented on
     $bundle = "IF (@col(body) <> '' AND @col(body) IS NOT NULL,@col(id),{$comment_if}) AS bundle_key";
     $query->select($bundle);
     $query->select('GROUP_CONCAT(DISTINCT @col(id)) AS ids');
     $query->select('GROUP_CONCAT(DISTINCT @col(owner.id))  AS  owner_ids');
     $query->select('GROUP_CONCAT(DISTINCT @col(target.id)) AS   target_ids');
     $query->select('GROUP_CONCAT(DISTINCT @col(comment.id)) AS  comment_ids');
     $query->select('GROUP_CONCAT(DISTINCT @col(object.id)) AS  object_ids');
     $query->select('GROUP_CONCAT(DISTINCT @col(subject.id)) AS subject_ids');
     $query->select(array('id' => 'MAX(@col(id))'));
     $query->select(array('creationTime' => 'MAX(@col(creationTime))'));
     $query->select(array('updateTime' => 'MAX(@col(updateTime))'));
     $viewer = get_viewer();
     $query->group('bundle_key');
     $query->order = array();
     $query->order('modified_on', 'DESC');
 }
예제 #23
0
 /**
  * Object constructor
  *
  * @param   object  An optional KConfig object with configuration options.
  */
 public function __construct(KConfig $config = null)
 {
     parent::__construct($config);
     $this->_document = $config->document;
     // Reset the row
     $this->reset();
     // Reset the row data
     if (isset($config->data)) {
         $this->setData(KConfig::unbox($config->data), $this->_new);
     }
 }
예제 #24
0
 /**
  * Set locations to a locatable node
  *
  * @param entity set of location entities
  */
 public function deleteLocation($locations)
 {
     $delete_ids = (array) KConfig::unbox($locations->id);
     foreach ($this->locations as $location) {
         if (in_array($location->id, $delete_ids)) {
             if ($edge = $this->locations->find($location)) {
                 $edge->delete();
             }
         }
     }
 }
예제 #25
0
 /**
  * Constructor.
  *
  * @param 	object 	An optional KConfig object with configuration options
  */
 public function __construct(KConfig $config)
 {
     $this->_repository = $config->mixer;
     parent::__construct($config);
     if (!empty($config->aliases)) {
         foreach ($config->aliases as $alias => $property) {
             $this->_mixer->getDescription()->setAlias($property, $alias);
         }
     }
     $this->_mixer->getDescription()->setAttribute(KConfig::unbox($config->attributes));
     $this->_mixer->getDescription()->setRelationship(KConfig::unbox($config->relationships));
 }
예제 #26
0
 /**
  *
  * Method to read child nodes of a folder
  *
  * @param array $config
  */
 public static function getNodes($config = array())
 {
     $config = new KConfig($config);
     $config->append(array('path' => null, 'type' => null, 'recurse' => false, 'fullpath' => false, 'filter' => null, 'map' => null, 'exclude' => array('.svn', '.git', 'CVS')));
     $exclude = KConfig::unbox($config->exclude);
     $filter = KConfig::unbox($config->filter);
     $map = KConfig::unbox($config->map);
     $recurse = $config->recurse;
     $results = array();
     foreach (new self($config->path) as $file) {
         if ($file->isDot() || in_array($file->getFilename(), $exclude)) {
             continue;
         }
         if ($file->isDir() && !$file->isDot() && $recurse) {
             $clone = clone $config;
             $clone->path = $file->getPathname();
             $clone->recurse = is_int($config->recurse) ? $config->recurse - 1 : $config->recurse;
             $child_results = self::getNodes($clone);
         }
         if ($config->type) {
             $method = 'is' . ucfirst($config->type === 'files' ? 'file' : 'dir');
             if (!$file->{$method}()) {
                 continue;
             }
         }
         if ($filter) {
             if (is_callable($filter)) {
                 $ignore = call_user_func($filter, rawurldecode($file->getPathname())) === false;
             } else {
                 if (is_array($filter)) {
                     $ignore = !in_array($file->getExtension(), $filter);
                 } else {
                     if (is_string($filter)) {
                         $ignore = !preg_match("/{$filter}/", $file->getFilename());
                     }
                 }
             }
             if ($ignore) {
                 continue;
             }
         }
         if (is_callable($map)) {
             $result = call_user_func($map, rawurldecode($file->getPathname()));
         } else {
             $result = $config->fullpath ? $file->getPathname() : $file->getFilename();
         }
         $results[] = $result;
         if (!empty($child_results)) {
             $results = array_merge($results, $child_results);
         }
     }
     return $results;
 }
예제 #27
0
파일: chain.php 프로젝트: stonyyi/anahita
 /**
  * Alias for the sanitize method.
  *
  * @param string $text   The text to be filtered
  * @param array  $config An Array of config
  *
  * @return string
  */
 public function filter($text, $config = array())
 {
     $context = $this->_chain->getContext();
     $context->data = $text;
     $context->config = $config;
     if ($context->config->filter) {
         $filter = (array) KConfig::unbox($context->config->filter);
         $filter[] = 'ptag';
         $context->config->filter = $filter;
     }
     $this->_chain->run('filter', $context);
     return $context->data;
 }
예제 #28
0
파일: editor.php 프로젝트: stonyyi/anahita
 /**
  * Generates an HTML editor
  *
  * @param   array   An optional array with configuration options
  * @return  string  Html
  */
 public function display($config = array())
 {
     $config = new KConfig($config);
     $config->append(array('editor' => null, 'name' => 'description', 'width' => '100%', 'height' => '500', 'cols' => '75', 'rows' => '20', 'buttons' => true, 'options' => array()));
     $editor = JFactory::getEditor($config->editor);
     $options = KConfig::unbox($config->options);
     if (version_compare(JVERSION, '1.6.0', 'ge')) {
         $result = $editor->display($config->name, $config->{$config->name}, $config->width, $config->height, $config->cols, $config->rows, KConfig::unbox($config->buttons), $config->name, null, null, $options);
     } else {
         $result = $editor->display($config->name, $config->{$config->name}, $config->width, $config->height, $config->cols, $config->rows, KConfig::unbox($config->buttons), $options);
     }
     return $result;
 }
예제 #29
0
 /**
  * Listbox for selecting application state in a column header
  *
  * @param  object  An optional KConfig object with configuration options.
  */
 public function application($config = array())
 {
     $config = new KConfig($config);
     $config->append(array('name' => 'application', 'deselect' => true, 'selected' => !is_array(KConfig::unbox($config->application)) ? $config->application : '', 'prompt' => '- Select -'));
     $options = array();
     if ($config->deselect) {
         $options[] = $this->option(array('text' => JText::_($config->prompt), 'value' => false));
     }
     $options[] = $this->option(array('text' => JText::_('Administrator'), 'value' => 'administrator'));
     $options[] = $this->option(array('text' => JText::_('Site'), 'value' => 'site'));
     $config->options = $options;
     return $this->optionlist($config);
 }
예제 #30
0
파일: helper.php 프로젝트: stonyyi/anahita
 /**
  * Applies an array of fiters to query by calling each filter as method
  * on the query.
  *
  * @param AnDomainQuery $query   Query Object
  * @param array         $filters An array of filter
  */
 public static function applyFilters($query, $filters)
 {
     foreach ($filters as $filter => $value) {
         $method = KInflector::variablize($filter);
         $value = KConfig::unbox($value);
         if (!is_array($value) || !is_numeric(key($value))) {
             $args = array($value);
         } else {
             $args = $value;
         }
         call_object_method($query, $method, $args);
     }
 }