コード例 #1
0
ファイル: locale.php プロジェクト: BackupTheBerlios/tip
 protected static function checkOptions(&$options)
 {
     if (!isset($options['locale'])) {
         return false;
     }
     // The 'data' option must be defined before calling parent::checkOptions()
     // so I can force the 'fieldset' option on the 'data' object
     isset($options['data']) || ($options['data'] = $options['id']);
     if (is_string($options['data'])) {
         $options['data'] = array('path' => TIP_Application::getGlobal('data_prefix') . $options['data'], 'fieldset' => array('id', $options['locale']));
     }
     return parent::checkOptions($options);
 }
コード例 #2
0
ファイル: template.php プロジェクト: BackupTheBerlios/tip
 /**
  * Check the options
  *
  * Builds an unique 'id' from the 'path' option (required).
  * It also checks for the template engine definition and
  * builds the template path, by checking its existence inside
  * "template_root" directory before and in "fallback_root" after.
  *
  * @param  array &$options Properties values
  * @return bool            true on success or false on error
  */
 protected static function checkOptions(&$options)
 {
     if (!isset($options['engine'])) {
         $options['engine'] =& TIP_Application::getGlobal('engine');
     }
     if (!isset($options['path']) || !$options['engine'] instanceof TIP_Template_Engine) {
         return false;
     }
     $path =& $options['path'];
     $engine =& $options['engine'];
     if (is_null($path = $engine->getTemplatePath($path))) {
         return false;
     }
     $options['id'] = implode(DIRECTORY_SEPARATOR, $path);
     return parent::checkOptions($options);
 }
コード例 #3
0
ファイル: application.php プロジェクト: BackupTheBerlios/tip
 public static function setRobots($index, $follow)
 {
     $robots =& TIP_Application::getGlobal('robots');
     $values = explode(',', $robots);
     if (is_bool($index)) {
         if ($index) {
             $old_value = 'noindex';
             $new_value = 'index';
         } else {
             $old_value = 'index';
             $new_value = 'noindex';
         }
         if (!in_array($new_value, $values)) {
             $key = array_search($old_value, $values);
             $key === false && ($key = count($values));
             $values[$key] = $new_value;
         }
     }
     if (is_bool($follow)) {
         if ($follow) {
             $old_value = 'nofollow';
             $new_value = 'follow';
         } else {
             $old_value = 'follow';
             $new_value = 'nofollow';
         }
         if (!in_array($new_value, $values)) {
             $key = array_search($old_value, $values);
             $key === false && ($key = count($values));
             $values[$key] = $new_value;
         }
     }
     $robots = implode(',', $values);
 }
コード例 #4
0
ファイル: content.php プロジェクト: BackupTheBerlios/tip
 /**
  * General db action manager
  *
  * Internal method used by _onAdd(), _onEdit() and _onDelete().
  *
  * @param  string      $action  'Add', 'Edit' or 'Delete'
  * @param  array      &$row     The subject row
  * @param  array|null  $old_row The old row or null on no old row
  * @return bool                 true on success or false on error
  * @internal
  */
 private function _onDbAction($action, &$row, $old_row)
 {
     // Dispatch the signal to all children modules
     $callback = create_function('$a', 'return @$a[\'master\'] == \'' . $this->id . '\';');
     if (is_array($children = array_filter($GLOBALS['cfg'], $callback))) {
         $method = '_onMaster' . $action;
         foreach (array_keys($children) as $child_id) {
             $child = TIP_Type::getInstance($child_id);
             if (method_exists($child, $method) && !$child->{$method}($row, $old_row)) {
                 return false;
             }
         }
     }
     // Update user statistics, if the user module exists
     if (!is_null($field = @$this->user_statistic['_on' . $action]) && !is_null($user =& TIP_Application::getSharedModule('user'))) {
         $user->increment($field);
     }
     // Remove the feed, if it exists
     if (!is_null($template =& TIP_Type::singleton(array('type' => array('template'), 'path' => array($this->id, $this->atom_template)))) && !is_null($path = $this->engine->getCachePath($template)) && file_exists($path)) {
         unlink($path);
     }
     return true;
 }
コード例 #5
0
ファイル: form.php プロジェクト: BackupTheBerlios/tip
 /**
  * Render the form
  *
  * @param  bool|null $valid Whether the form was validated
  * @return bool             true if the renderer was performed,
  *                          false on errors
  */
 public function render($valid)
 {
     $mode = $valid === false ? $this->invalid_render : $this->valid_render;
     if ($mode == TIP_FORM_RENDER_NOTHING) {
         return true;
     } elseif ($mode == TIP_FORM_RENDER_REDIRECT) {
         // Pass a notification message throught the session
         if ($valid === false) {
             $notify = array(TIP_SEVERITY_ERROR, $this->action_id);
         } elseif ($this->notify_done) {
             $notify = array(TIP_SEVERITY_INFO, 'done');
         }
         isset($notify) && HTTP_Session2::set('notify', $notify);
         // Forcibly close the current session
         HTTP_Session2::pause();
         // Perform the redirection
         HTTP::redirect($this->follower, true);
     }
     if ($this->_stage > 1) {
         foreach ($this->_trailing_elements as &$element) {
             // Update the tabindex property
             ++$this->_tabindex;
             $element->setAttribute('tabindex', $this->_tabindex);
             $this->_form->addElement($element);
         }
     }
     // Execute the prerender callbacks
     foreach ($this->_prerender as $field => $data) {
         call_user_func_array($data['callback'], $data['args']);
     }
     // Add buttons
     $this->_addButtons($valid);
     // Form template initialization
     $template =& TIP_Application::getSharedTemplate($this->form_template);
     if (is_null($template)) {
         TIP::error("form template not found ({$this->form_template})");
         return false;
     }
     $this->_form->setRequiredNote($this->getLocale('label.requirednote'));
     // Some global keys
     $this->keys['ATTRIBUTES'] = $this->_form->getAttributes(true);
     // DEPRECATED: the tag {form(getRequiredNote)} must be used instead
     $this->keys['REQUIREDNOTE'] = $this->_form->getRequiredNote();
     // Populate the array (if not yet done)
     if (is_null($this->_array)) {
         $renderer =& TIP_Renderer::getForm();
         $this->_form->accept($renderer);
         $this->_array = $renderer->toArray();
     }
     // Call the renderer
     if ($mode == TIP_FORM_RENDER_IN_PAGE) {
         $content =& TIP_Application::getGlobal('content');
         ob_start();
         $done = $template->run($this);
         $content .= ob_get_clean();
     } else {
         $done = $template->run($this);
     }
     return $done;
 }
コード例 #6
0
ファイル: devhelp2.php プロジェクト: BackupTheBerlios/tip
 /**
  * Perform a view action
  *
  * Runs the file identified by the 'view_template' property for the
  * specified row. The rendered result is appended to the page.
  *
  * @param  mixed $id The identifier of the row to view
  * @return bool      true on success or false on errors
  */
 protected function actionView($id)
 {
     // The query is not strictly necessary but it is still performed
     // to avoid read actions on arbitrary files
     if (is_null($row =& $this->fromRow($id, false)) || !$this->_onView($row)) {
         return false;
     }
     // Check for html file existence
     $file = TIP::buildDataPath($this->id, $id);
     if (!is_readable($file)) {
         $this->endView();
         return false;
     }
     $content =& TIP_Application::getGlobal('content');
     $this->keys['id'] = $id;
     $this->keys[$this->title_field] = str_replace('.html', '', $id);
     $this->keys['content'] = file_get_contents($file);
     $this->keys[$this->creation_field] = TIP::formatDate('datetime_sql', filectime($file));
     $this->keys[$this->edited_field] = TIP::formatDate('datetime_sql', filemtime($file));
     if (empty($this->view_template)) {
         // On empty template, output the whole html file content
         // and set a viable "title" metatag
         $content .= $this->keys['content'];
         $title =& TIP_Application::getGlobal('title');
         $title = $this->keys[$this->title_field] . ' (' . $title . ')';
     } else {
         // Use a custom template
         $content .= $this->tagRun($this->view_template);
     }
     // Discard the generated content to decrease memory consumption
     unset($this->keys);
     $this->endView();
     return true;
 }
コード例 #7
0
ファイル: hierarchy.php プロジェクト: BackupTheBerlios/tip
 /**
  * Echo the hierarchy
  *
  * Overrides the default tagShow() to disable the page indexing
  * if the current selected row is a container. In $params you can
  * specify the custom action to use: if left empty, the default
  * action (configured for this module) will be used.
  */
 protected function tagShow($params)
 {
     // Backward compatibility
     empty($params) && ($params = $this->action);
     if (is_null($renderer = $this->_getRenderer($params))) {
         return null;
     }
     if ($renderer->isCurrentContainer()) {
         // If the current row is a container, don't index this page
         TIP_Application::setRobots(false, null);
     }
     return $renderer->toHtml();
 }
コード例 #8
0
ファイル: Type.php プロジェクト: BackupTheBerlios/tip
 /**
  * Type instantiation
  *
  * Gets the singleton of a configured object. $id could be any identifier
  * defined in $GLOBALS['cfg'].
  *
  * An internal register is mantained to avoid singleton() calls with the
  * same $id.
  *
  * @param  mixed    $id       Instance identifier
  * @param  bool     $required true if errors must be fatals
  * @return TIP_Type           The reference to the requested instance or
  *                            false on errors
  */
 public static function &getInstance($id, $required = true)
 {
     static $register = array();
     global $cfg;
     $id = strtolower($id);
     if (class_exists('TIP_Application')) {
         $namespace = TIP_Application::getGlobal('namespace');
         if (!empty($namespace) && isset($cfg[$namespace . '_' . $id])) {
             $id = $namespace . '_' . $id;
         }
     }
     if (array_key_exists($id, $register)) {
         return $register[$id];
     }
     if (isset($cfg[$id])) {
         $options = $cfg[$id];
         isset($options['id']) || ($options['id'] = $id);
         $instance =& TIP_Type::singleton($options);
     } else {
         $instance = null;
     }
     if (is_null($instance) && $required) {
         TIP::fatal("unable to instantiate the requested object ({$id})");
         exit;
     }
     $register[$id] =& $instance;
     return $instance;
 }
コード例 #9
0
ファイル: module.php プロジェクト: BackupTheBerlios/tip
 /**
  * Build an icon URI
  */
 protected function tagIconUri()
 {
     $pieces = func_get_args();
     return TIP::buildUri(TIP_Application::getGlobal('icon_root'), $pieces);
 }
コード例 #10
0
ファイル: TIP.php プロジェクト: BackupTheBerlios/tip
 /**
  * Constuctor
  */
 public function __construct()
 {
     $this->_user =& TIP_Application::getSharedModule('user');
 }
コード例 #11
0
ファイル: user.php プロジェクト: BackupTheBerlios/tip
 protected function runAdminAction($action)
 {
     switch ($action) {
         case 'view':
             // Moved from runAction()
             return $this->actionView(TIP_Application::getGlobalItem('ID'));
     }
     return parent::runAdminAction($action);
 }
コード例 #12
0
ファイル: TIP.php プロジェクト: BackupTheBerlios/tip
 /**
  * Get the default fallback privilege for the specified module
  *
  * Returns the default privilege for a module and a specified user.
  *
  * @param  string           $module The requesting module identifier
  * @param  mixed            $user   A user id
  * @return TIP_PRIVILEGE...         The requested privilege
  */
 public static function getDefaultPrivilege($module, $user)
 {
     $privilege_type = $user ? 'default_privilege' : 'anonymous_privilege';
     $result = @$GLOBALS['cfg'][(string) $module][$privilege_type];
     if (is_null($result)) {
         $result = TIP_Application::getGlobal($privilege_type);
     }
     return $result;
 }
コード例 #13
0
ファイル: chronology.php プロジェクト: BackupTheBerlios/tip
 /**
  * Perform a browse action
  *
  * In $conditions, you must specify an associative array of
  * 'field_id' => 'value' to impose for this browse action. Only equal
  * conditions are allowed.
  *
  * @param  array &$conditions The browse conditions
  * @return bool               true on success or false on errors
  */
 protected function actionBrowse($id)
 {
     if (!TIP_AHAH) {
         // Browse actions implemented only as AHAH response
         return false;
     }
     sscanf($id, '%04s%02s', $year, $month);
     if (!$year || !$this->_render()) {
         return false;
     }
     if (array_key_exists($year, $this->_tree)) {
         $tree =& $this->_tree[$year]['sub'];
     } else {
         return true;
     }
     if (array_key_exists($id, $tree)) {
         $tree =& $tree[$id]['sub'];
     } elseif (isset($month)) {
         return true;
     }
     require_once 'HTML/Menu.php';
     $model =& new HTML_Menu($tree);
     $renderer =& TIP_Renderer::getMenu(0);
     $model->render($renderer, 'sitemap');
     $content =& TIP_Application::getGlobal('content');
     $content .= $renderer->toHtml();
     return true;
 }
コード例 #14
0
ファイル: expiration.php プロジェクト: BackupTheBerlios/tip
 /**
  * 'on_process' callback for unflag actions
  *
  * This is the reverse operation of _onFlag(), and set the
  * flag field to "no".
  *
  * @param  array &$row The row to flag
  * @return bool        true on success or false on errors
  */
 public function _onUnflag(&$old_row)
 {
     if (!isset($this->flag_field)) {
         // No flag field defined: silently returns true
         return true;
     }
     $flagger = @$old_row[$this->flagger_field];
     $flagged = @$old_row[$this->owner_field];
     $row[$this->flag_field] = 'no';
     if (!$this->data->updateRow($row, $old_row)) {
         return false;
     }
     $user = TIP_Application::getSharedModule('user');
     if (!$user) {
         // User module not available: no statistic update required
         return true;
     }
     // Update statistics of the flagging user
     if (isset($flagger, $this->unflaggee_field) && !is_null($view = $user->startDataView($user->getProperty('data')->rowFilter($flagger)))) {
         $row = $view->current();
         $user->endView();
         if (!is_null($row)) {
             $old_row = $row;
             ++$row[$this->unflaggee_field];
             $user->getProperty('data')->updateRow($row, $old_row);
         }
     }
     // Update statistics of the flagged user
     if (isset($flagged, $this->unflagged_field) && !is_null($view = $user->startDataView($user->getProperty('data')->rowFilter($flagged)))) {
         $row = $view->current();
         $user->endView();
         if (!is_null($row)) {
             $old_row = $row;
             ++$row[$this->unflagged_field];
             $user->getProperty('data')->updateRow($row, $old_row);
         }
     }
     return true;
 }